Yes No Cancel Dialog Box

6 posts, 1 answers
  1. Scott
    Scott avatar
    35 posts
    Member since:
    Sep 2012

    Posted 20 Apr 2013 Link to this post

    I am surprised I cannot find any guidance on how to do a CLIENT-side Yes / No / Cancel dialog box using Telerik Rad controls for ASP.NET AJAX.  My best guess is the RadNotification control, but still I cannot find any guidance on how to do this, in either the online documentation or by searching the Forums,  Could you please point me to a helpful posting or documentation page on this topic, one that has some sample code?
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Apr 2013 Link to this post

    Hi,

    Please have a look at the following code.

    ASPX:
    <telerik:RadButton ID="RadButton1" runat="server" Text="Delete" OnClientClicking="showConfirmRadWindow"
        OnClick="RadButton1_Click">
    </telerik:RadButton>
    <telerik:RadWindow ID="confirmWindow" runat="server" VisibleTitlebar="true" 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>

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        Label l1 = new Label();
        this.form1.Controls.Add(l1);
        l1.Text = "File Deleted";
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 22 Apr 2013 Link to this post

    Hi guys,

    I would advise that you examine a simpler alternative - the predefined dialogs from the RadWindowManager control: http://demos.telerik.com/aspnet-ajax/window/examples/browserdialogboxes/defaultcs.aspx. The demo shows them in action and more detailed information is available in the documentation: http://www.telerik.com/help/aspnet-ajax/window-dialogs-confirm.html.


    Greetings,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Scott
    Scott avatar
    35 posts
    Member since:
    Sep 2012

    Posted 22 Apr 2013 Link to this post

    Thanks, Princy.  I had to add the third button I wanted (Cancel) and replace the "args.set_cancel(true)" with "return false", but then it worked.

  6. Scott
    Scott avatar
    35 posts
    Member since:
    Sep 2012

    Posted 22 Apr 2013 Link to this post

    Marin, I agree the pre-defined Confirm is easier, but since I was looking for a 3-button dialog (Yes / No / Cancel), I went with the RadWindow approach.
  7. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 23 Apr 2013 Link to this post

    Hello,

    I am glad you have the desired effect working, I just wanted to note that you can add another button by modifying the confirm template as shown here: http://www.telerik.com/help/aspnet-ajax/window-dialogs-changing-dialog-templates.html.


    Greetings,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017