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

set_autoPostBack false and true not posting back

1 Answer 225 Views
Button
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 31 Oct 2014, 11:31 AM
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

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 04 Nov 2014, 09:23 AM
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.

 
Tags
Button
Asked by
Frank
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or