Prevent double clicking asp.net button
Prevent Double Click .Please add below code in your aspx page.
<script type="text/javascript" language="javascript"> Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler); function BeginRequestHandler(sender, args) { var oControl = args.get_postBackElement(); oControl.disabled = true; }</script>
This solution is simple and effective. On your button include this code:
OnClientClick="return CheckDouble();"
And wherever you want your JavaScript - e.g. At the bottom of your page:
<script type="text/javascript"> var submit = 0; function CheckDouble() { if (++submit > 1) { alert('This sometimes takes a few seconds - please be patient.'); return false; } } </script>
You can prevent double-clicking using this code:
Me.btnSave.Attributes.Add("onclick", "this.disabled=true;")Me.btnSave.UseSubmitBehavior = False
So you can use btnSave_Click
to call your API.
Usually I have a lot of Validators
in my Page
: setting Validator.SetFocusOnError = True
I can run this code to reenable save button if a validation failed.
Me.YourControl.Attributes.Add("onfocus", Me.btnSave.ClientID & ".removeAttribute('disabled');")