4

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 Answers 2

9

This is shorter ;)

$("#<%=delButton.ClientID%>").val('InActivate');
Sign up to request clarification or add additional context in comments.

1 Comment

The only note I would make to this is that if the object created is <button> and not <input type="button"> than this doesn't work. You could then use $("#<%=delButton.ClientID%>").text('InActivate');
1

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

<%= delButton.ClientID %>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.