← Tutti gli articoli
How to prevent double click on Ajax Asp.Net WebForm
11 May 2011 ·
Asp.Net · Article ·
849 visite
Needed a simple way to protect all the forms on our site from being double submitted.
This is the JavaScript source for method get_postBackElement() from ASP.NET AJAX Library. Full name for this method is Sys$WebForms$BeginRequestEventArgs$get_postBackElement(). It belongs to the class BeginRequestEventArgs, which is in Sys.WebForms namespace. This source is in MicrosoftAjaxWebForms.debug.js file.
- <script type= "text/javascript" >
- Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginReq);
- Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endReq);
- var ctrl = null;
- function beginReq(sender, args) {
- ctrl = args.get_postBackElement(); //the control causing the postback
- ctrl.disabled = true;
- // shows the Popup
- $find('<%= ModalProgress.ClientID %>').show();
- }
- function endReq(sender, args) {
- ctrl.disabled = false;
- ctrl = null;
- // shows the Popup
- $find('<%= ModalProgress.ClientID %>').hide();
- }
- </script>