Changing Text of asp:Button using Jquery

11.5k views Asked by At

Am trying to change text of an asp:Button using jQuery Like this

  $("#<%=delButton.ClientID%>").attr('text', 'InActivate');
  .....
  <asp:Button ID="delButton" runat="server" UseSubmitBehavior="false" Text="Activate "    
   CssClass="button"   ToolTip="" OnClientClick="ondel();return false;"/>

I can see the text changing, Is the proper way to do?

Thanks

2

There are 2 answers

1
Alex Dn On BEST ANSWER

This is shorter ;)

$("#<%=delButton.ClientID%>").val('InActivate');
0
Andomar On

Yes, that's the best way I know of. This will get you the right client id regardless of clientIDMode:

<%= delButton.ClientID %>