How can I disable or enable button in asp.net? I want to disable button after click to prevent double click. I am trying to disable my Login button after clicking on it.
To disable a button using only JavaScript you need to set its disabled property to false . For example: element. disabled = true . And to enable a button we would do the opposite by setting the disabled JavaScript property to false .
Answers. If you just want to disable it and nothing else, then add attribute Enabled = "false".
You have to disable it on client so that user could not click it again.
<asp:button id="btn" runat="server" OnClientClick="this.disabled=true;"......
To disable on server side asp.net code.
btn.Enabled = false;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With