How to use RadWindow as RadButton Confirm Dialog.

2 posts, 1 answers
  1. Ben
    Ben avatar
    31 posts
    Member since:
    Feb 2013

    Posted 17 Feb 2013 Link to this post

    Hi,

    I have a RadWindow and I need to display it as a confirm dialog on my Delete RadButton Click. I am setting my Button postback from JavaScript but I think its not working correctly. Please help me with code.

    Thanks,
    Ben.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Feb 2013 Link to this post

    Hi,

    Please try the following code to display the RadWindow as a confirm dialog for your RadButton. Initially you need to set the AutoPostBack property of the Yes and No buttons inside the RadWindow to false.

    ASPX:
    <telerik:RadButton ID="RadButton1" runat="server" Text="Delete" OnClientClicking="showConfirmRadWindow"
        OnClick="RadButton1_Click">
    </telerik:RadButton>
    <telerik:RadWindow ID="confirmWindow" runat="server" VisibleTitlebar="false" VisibleStatusbar="false"
        Modal="true" Behaviors="None" Height="150px" Width="300px">
        <ContentTemplate>
            <div style="padding-left: 30px; padding-top: 20px; width: 200px; float: left;">
                <asp:Label ID="lblConfirm" Font-Size="14px" Text="Are you sure you want to Delete?"
                    runat="server"></asp:Label>
                <br />
                <br />
                <telerik:RadButton ID="RadButtonYes" runat="server" Text="Yes" AutoPostBack="false"
                    OnClientClicked="confirmResult">
                </telerik:RadButton>
                <telerik:RadButton ID="RadButtonNo" runat="server" Text="No" AutoPostBack="false"
                    OnClientClicked="confirmResult">
                </telerik:RadButton>
            </div>
        </ContentTemplate>
    </telerik:RadWindow>

    JavaScript:
    <script type="text/javascript">
        function showConfirmRadWindow(sender, args) {
            $find("<%=confirmWindow.ClientID %>").show();
            $find("<%=RadButtonYes.ClientID %>").focus();
            args.set_cancel(true);
        }
        function confirmResult(sender, args) {
            var oWnd = $find("<%=confirmWindow.ClientID %>");
            oWnd.close();
            if (sender.get_text() == "Yes") {
                $find("<%=RadButton1.ClientID %>").click();
            }
        }
    </script>

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