I have forms with payment in ASP.NET site, when user clicks on asp:Button sometime he submits few times. I want to disable this functionality without harming current ASP.NET site ( by that i mean no fancy jQuery, unless it is very basic and will not interfere with ASP.NET built-in validation)
thanks!!!
Enable / Disable submit button 1.1 To disable a submit button, you just need to add a disabled attribute to the submit button. $("#btnSubmit"). attr("disabled", true); 1.2 To enable a disabled button, set the disabled attribute to false, or remove the disabled attribute.
(1)you can disable the controls in javascript and then use GetPostBackEventReference( button id) to submit the webpage. (2)You can use Session to store flag to prevent "double posts". Please check out the following article. u can disable the button by JS using clientside onClick event.
You can easily do this on the button in client side:
onClientClick="this.disabled=true;"
You can also use the approach from Muhammad with this:
onClientClick="if(Page_ClientValidate()){this.disabled=true;}"
If this is still not working, you can initiate the postback yourself before disabling the button:
onClientClick="if(Page_ClientValidate()){__doPostBack;this.disabled=true;}"
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