Tuesday, February 9, 2021

Prevent double clicking asp.net button

.Please add below code in your aspx page.If you get Error: 'Sys' is undefined when using this then it is because you need a ScriptManager on the 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>

OR code side

          ' To disable multiple clicks on Save button
                btnTransfer.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btnTransfer, Nothing) + ";")
                'To disable multiple clicks on Save button

No comments:

Post a Comment