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

How to use RadWindow as RadButton Confirm Dialog.

1 Answer 494 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 18 Feb 2013, 03:52 AM
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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 18 Feb 2013, 05:28 AM
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.
Tags
Window
Asked by
Ben
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or