SingleClick RadButton - Re-Enabling after radProgressArea Cancel Click

3 posts, 1 answers
  1. Top Coder
    Top Coder avatar
    18 posts
    Member since:
    May 2005

    Posted 23 Oct 2015 Link to this post

    I have a form with a rad button, with single click enabled. 

    On that form I have a RadProgressArea with the cancel button. 

    When the cancel button is pressed on the RadProgressArea - The RadButton doesn't re-enable.

    How do I get it to re-enable, I tried the code below, but the button remains in it's disabled state. 

    If Not Response.IsClientConnected Then
        'Cancel button was clicked or the browser was closed, so stop processing
        radbutton.enabled = true
        exit sub
    end if

                             

  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 27 Oct 2015 Link to this post

    Hi,

    The Single Click feature of RadButton waits for the postback to return in order to re-enable the button. RadProgressArea uses a separate handler for its update and RadButton cannot monitor that as well.

    Nevertheless, you can re-enable the button via its client-side API (http://docs.telerik.com/devtools/aspnet-ajax/controls/button/client-side-programming/overview):

    <telerik:RadButton ID="RadButton1" runat="server" Text="Submit" SingleClick="true" SingleClickText="Please wait..." OnClick="RadButton1_Click">
    </telerik:RadButton>
    <asp:Button ID="Button1" Text="click me within 5 seconds of the postback" OnClientClick="reEnable(); return false;" runat="server" />
    <script>
        function reEnable() {
            var btn = $find("<%=RadButton1.ClientID%>");
            btn.enableAfterSingleClick();
        }
    </script>
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(5000);
    }

    To get the click on the progress area Cancel button, you can attach a handler to it:

    <script>
        function reEnable() {
            var btn = $find("<%=RadButton1.ClientID%>");
            btn.enableAfterSingleClick();
        }
        function attachHandlersToCancelButton() {
            $telerik.$(".ruCancel", $find("<%=RadProgressArea1.ClientID%>").get_element()).on("mousedown", reEnable);
        }
    </script>
    <telerik:RadButton ID="RadButton1" runat="server" Text="Submit" SingleClick="true" SingleClickText="Please wait..." OnClick="RadButton1_Click" OnClientClicking="attachHandlersToCancelButton">
    </telerik:RadButton>

    where you may want to remove the handler when it is called to avoid attaching it multiple times and the server code can be taken directly from the Custom progress article: http://docs.telerik.com/devtools/aspnet-ajax/controls/progressarea/custom-progress.

    Regards,

    Marin Bratanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Top Coder
    Top Coder avatar
    18 posts
    Member since:
    May 2005

    Posted 04 Nov 2015 in reply to Marin Bratanov Link to this post

    Thanks a lot, Marin. 

    Your solution worked!

Back to Top