Telerik: preventing postback using the RadButton confirmation dialog

I had a problem implementing the confirmation dialog to ask the user to confirm their choice for deletion. RadButton should not return the server if the user clicks the Cancel button. Does the confirmation dialog never show what I'm doing wrong?

<script type="text/javascript">
    function confirmAspButton(button) {
        function aspButtonCallbackFn(arg) {
            if (arg) {
                __doPostBack(button.name, "");
            }
        }
        radconfirm("Are you sure you want to delete?", aspButtonCallbackFn, 330, 110, null, "Confirm");
    }
</script>


<telerik:RadButton
    ID="btnDeleteLines" 
    runat="server" 
    OnClientClicking="confirmAspButton(this); return false;"
    OnClick="btnDeleteLines_Click"
    Text="Delete line(s)"
    AutoPostBack="false"
    GroupName="GroupName1">
</telerik:RadButton>
+3
source share
1 answer

Well, I learned the method described on the website telerik , CustomRadWindowConfirm.

<script type="text/javascript">
    //Custom RadWindow Confirm
    function CustomRadWindowConfirm(sender, args)
    {
        //Open the window
        $find("<%= confirmWindow.ClientID %>").show();
        //Focus the Yes button
        $find("<%= btnYes.ClientID %>").focus();
        //Cancel the postback
        args.set_cancel(true);
    }
    function YesOrNoClicked(sender, args)
    {
        var oWnd = $find("<%= confirmWindow.ClientID %>");
        oWnd.close();
        if (sender.get_text() == "Yes")
        {
            $find("<%= btnDeleteLines.ClientID %>").click();
        }
    }
</script>


<telerik:RadButton
    ID="btnDeleteLines" 
    runat="server" 
    OnClientClicking="CustomRadWindowConfirm"
    OnClick="btnDeleteLines_Click"
    Text="Delete line(s)"
    AutoPostBack="false"
    GroupName="GroupName1">
</telerik:RadButton>
+5
source

Source: https://habr.com/ru/post/1599243/


All Articles