You may want to disable control during AJAX, so the clients won't be able to use it before response end. This could easy be achieved using OnRequestStart and OnResponseEnd client-side events changing the disabled value.
Here is a complete working code showing the mentioned approach:
| JavaScript |
Copy Code |
|
<script type="text/javascript"> function RequestStart(sender, args) { args.EventTargetElement.disabled = true; } function ResponseEnd(sender, args) { args.EventTargetElement.disabled = false; } </script> |
| ASPX/ASCX |
Copy Code |
|
<asp:Button ID="btnUpdate" runat="server" Text="Update" /> <asp:Label ID="Label1" runat="server"></asp:Label>
<rad:RadAjaxManager ID="RadAjaxManager1" runat="server" > <AjaxSettings> <rad:AjaxSetting AjaxControlID="btnUpdate"> <UpdatedControls> <rad:AjaxUpdatedControl ControlID="Label1"/> </UpdatedControls> </rad:AjaxSetting> </AjaxSettings> <ClientEvents OnRequestStart="RequestStart" OnResponseEnd="ResponseEnd" /> </rad:RadAjaxManager> |
Implementing the above will disable any control, which has already start a request until its response ends.
If one wants to disable AJAX until the current response finishes, no matter which control has started the first request and which is going to make a second one, a global flag may be used as in the following script:
| JavaScript |
Copy Code |
|
<script type="text/javascript"> var AjaxIsActive = false;
function RequestStart() { if (!AjaxIsActive) { AjaxIsActive = true; } else { alert( return false; } }
function ResponseEnd() { AjaxIsActive = false; } </script> |