ShareThis

Wednesday, July 18, 2012

How to disable an asp button with runat="server" from javascript

The reason this doesnt work with the asp button's ID is because this ID is not the actual ID on the client side. Instead, you will want to use the button.ClientID.

You can set the client state value of the ClientID on the C# class for the page. In the javascript, you can get the client state value and use jQuery or document.getElementById(...) using the value returned from the client state value.

From there, it is as simple as :



$("#myButton").attr("disabled", "true"); 
$("# myButton ").removeAttr("disabled");


0 comments:

Post a Comment