Introduction
You can access label value using any event like button client click
define javascript function like below.
handle postback in page load of page as below.
VB.Net
C#.Net
You can access label value using any event like button client click
<asp:Label ID="lbltext" runat="server" CssClass="cssTextLabel" Text="Test"></asp:Label> <asp:Button ID="btnGetLabelData" runat="server" OnClientClick="GetData()" />
define javascript function like below.
<script type="text/javascript"> function GetData() { var lbltxt = $.find('span.cssTextLabel')[0].innerHTML __doPostBack('GET_DATA', lbltxt); } </script>
handle postback in page load of page as below.
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim strLblData As String = String.Empty If Request("__EVENTTARGET") = "GET_DATA" Then strLblData = Request("__EVENTARGUMENT").ToString() Response.Write(strLblData) End If End Sub
C#.Net
protected void Page_Load(object sender, System.EventArgs e) { string strLblData = string.Empty; if (Request("__EVENTTARGET") == "GET_DATA") { strLblData = Request("__EVENTARGUMENT").ToString(); Response.Write(strLblData); } }I hope this article was useful and I thank you for viewing it. keep visiting blog , you can get more stuff.
No comments:
Post a Comment