set_autoPostBack false and true not posting back

2 posts, 0 answers
  1. Frank
    Frank avatar
    24 posts
    Member since:
    Nov 2010

    Posted 31 Oct 2014 Link to this post

    Since we updated our RadControls to the latest version, we noticed the clientside set_autoPostBack functionality has changed.

     
    If you want a confirmation from the user before the button is posted, we set the autopostback to false. Once all is confirmed we put it back on true.

    Like:
    <head runat="server">
        <script>
            function ConfirmButton(button, args) {
                button.set_autoPostBack(false);
                 
                if( confirm('Are you sure?'))
                    button.set_autoPostBack(true);
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:radscriptmanager runat="server" />
            <asp:Literal runat="server" ID="ltStatus" /><br/>
            <telerik:radbutton id="btnCredit" runat="server" text="DoPostback?" onclientclicked="ConfirmButton" onclick="btnCredit_OnClick" />
        </form>
    </body>

    When you confirm, the button doesn't get postbacked.
    Introducing a var with the confirmvalue will work, but why is this ?

    <script>
        function ConfirmButton(button, args) {
            var setPostback = false;
            if (confirm('Are you sure?'))
                setPostback = true;
     
            button.set_autoPostBack(setPostback);
        }
    </script>


    Our previous Telerik Version was 2013.1.504.40

    Thanks in advance

  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1494 posts

    Posted 04 Nov 2014 Link to this post

    Hello Frank,

    I would suggest when you want to cancel a postback you use the accepted and officially documented approach - set the set_cancel(true) method of the event argument of OnClientClicking event. See an example in the OnClientClicking help article.

    As for the set_autoPostBack() method, in order to use it in events make sure that this happens at an earlier stage(i.e., the cancellable OnClientClicking  event and not the OnClientClicked event).

    Regards,
    Danail Vasilev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top