Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > Window > RadConfirm from code behind

Not answered RadConfirm from code behind

Feed from this thread
  • Posted on Oct 22, 2010 (permalink)

    Requirements

    RadControls version

    2010, 1, 519, 35
    .NET version

    3.5 SP1
    Visual Studio version

    2008
    programming language

    C#, Javascript
    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION
    The project demonstrates how to call a radConfirm from code behind and how to retrieve its response in server side. The radconfirm is shown by following the similar approach described in KB Article and uses ajaxRequest to pass the result to server.

    ASPX:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadConfirm.aspx.cs" Inherits="_Default" %>
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="Label1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
            </telerik:RadWindowManager>
            <br />
            <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
            <br />
            <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
        </div>
        </form>
    </body>
    </html>
     
    <script type="text/javascript">
        function callConfirm() {
            radconfirm('Are you sure?', confirmCallBackFn);
        }
        function confirmCallBackFn(arg) {
            var ajaxManager = $find("<%=RadAjaxManager1.ClientID%>");
            if (arg) {
                ajaxManager.ajaxRequest('ok');
            }
            else {
                ajaxManager.ajaxRequest('cancel');
            }
        }
    </script>

    C#:
    protected void Button2_Click(object sender, EventArgs e)
       {
           string radalertscript = "<script language='javascript'>function f(){callConfirm(); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
           Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript);
       }
       protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
       {
           if (e.Argument.ToString() == "ok")
           {
               Label1.Text="OK";
           }
           else
           {
               Label1.Text = "Cancel";
           }
       }

    Thanks,
    Princy.
    Attached files

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > Window > RadConfirm from code behind