How to set text to label with jQuery? How to set text to label with jQuery? jquery jquery

How to set text to label with jQuery?


If your button is causing a postback then the changes will be lost after the page has reloaded. Try this -

function f()         {            $('#<%=Label1.ClientID%>').html("hello");             return false;          }


Labels do not maintain viewstate. The server will not post that information back to the server. You can try explicitly enabling the ViewState on your Label, but if that doesn't work, you will have to store that value in a hidden field.

<asp:Label ID="Label1" runat="server" EnableViewState="true"></asp:Label>


You can use text method to set the text

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="return f();"/>function f()     {        $('#<%=Label1.ClientID%>').html("hello");         return false;      }