Disable button to avoid double-click

2 posts, 1 answers
  1. Bader
    Bader avatar
    215 posts
    Member since:
    Aug 2008

    Posted 31 Jan 2012 Link to this post

    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
  2. Answer
    Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 01 Feb 2012 Link to this post

    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
Back to Top