RadControls for ASP.NET AJAX 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:
CopyASPX
<script type="text/javascript">
function RequestStart(sender, args) {
args.EventTargetElement.disabled = true;
}
function ResponseEnd(sender, args) {
args.EventTargetElement.disabled = false;
}
</script>
<asp:Button ID="btnUpdate" runat="server" Text="Update" />
<asp:Label ID="Label1" runat="server"></asp:Label>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="btnUpdate">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Label1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
<ClientEvents OnRequestStart="RequestStart" OnResponseEnd="ResponseEnd" />
</telerik: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:
CopyJavaScript
var AjaxIsActive = false;
function RequestStart() {
if (!AjaxIsActive) {
AjaxIsActive = true;
}
else {
alert('Wait for ajax to finish'); return false;
}
}
function ResponseEnd() {
AjaxIsActive = false;
}