This is a migrated thread and some comments may be shown as answers.

Disable button to avoid double-click

1 Answer 407 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Bader
Top achievements
Rank 1
Bader asked on 31 Jan 2012, 05:17 PM
Hi,

I'm trying to disable the button by clicking submit (In order to avoid double-click from the user). Below the code which I'm using:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function RequestStart(sender, args) {
var submitButton = $get("<%= EditButton.ClientID %>");
submitButton.disabled = true;
}
</script>
</telerik:RadCodeBlock
<telerik:RadAjaxPanel ID="MainRadAjaxPanel" runat="server" LoadingPanelID="MainRadAjaxLoadingPanel" ClientEvents-OnRequestStart="RequestStart" >
....... The form controls ....
<asp:Button ID="EditButton" runat="server" Text="Edit" SkinID="NormalButton" OnClick="EditButton_Click" />
</telerik:RadAjaxPanel>

Since the above javascript function is needed to be used in many pages in the website, and the submit button name may be changed (For example: EditButton, SubmitButton, ChangeButton ....), I'm wonder If it is possible to find the submit button name and to disable it using the above javascript.

Please, I need your help.

Regards,
Bader

1 Answer, 1 is accepted

Sort by
0
Accepted
Maria Ilieva
Telerik team
answered on 01 Feb 2012, 04:56 PM
Hi Bader,

You could use the ajax EventTargetElement which the actual ajax initiator instead of the button id in the client code. See the following help topic form more information on this matter:
http://www.telerik.com/help/aspnet-ajax/ajax-disable-controls-during-ajax.html

All the best,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Ajax
Asked by
Bader
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or