Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Window / Returning Values from a Dialog

This demo contains 1 or more dialog pages. To view them, hover over the dropdown button () in the Example Source Code & Description section

Click the button to open the Travel Planner form in a RadWindow.




  •  Travel Planner

    This example demonstrates a common real-world scenario - opening a dialog from another dialog and ensuring the communication between them and the parent page.

    In this particular example, a new RadWindow is opened from within another RadWindow in the context of the parent page. To build the communication between the popups and the parent page, we use RadWindow's client-side API. The following methods and properties are used:
    • BrowserWindow - this property returns a reference to the parent page from which the RadWindow was opened.
    • get_contentFrame() - this method returns a reference to the IFRAME, in which the content page of the RadWindow is displayed. To gain access to the content page itself, you need to use its contentWindow property, e.g.
      get_contentFrame().contentWindow.
    • When the initial RadWindow is closed, the argument from within it is transferred to the parent page in the close() function and is read in the OnClientClose function on the parent page.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.Web.Examples.Window.DialogReturnValue.DefaultCS" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <style type="text/css">
                .orderText
                {
                    font: normal 12px Arial,Verdana;
                    margin-top: 6px;
                }
                .expandImage
                {
                    display: inline-block;
                    background-image: url('<%= Page.ResolveUrl("~/Common/styles09/sprite09.gif")%>');
                    background-position: -596px -1191px;
                    background-repeat: no-repeat;
                    width: 15px;
                    height: 15px;
                }
                * html .expandImage
                {
                    background-position: -596px -1194px;
                }
                * + html .expandImage
                {
                    background-position: -596px -1194px;
                }
            </style>
        </telerik:RadCodeBlock>
    </head>
    <body class="BODY">
        <form id="form1" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="c#" ShowSkinChooser="false" />
        <qsf:InformationBox ID="InformationBox1" runat="server">
            <span style="font-size: 12px;">This demo contains 1 or more dialog pages. To view them,
                hover over the dropdown button (<span class="expandImage"></span>) in the <em>Example
                    Source Code &amp; Description</em> section</span>
        </qsf:InformationBox>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Sunset" />
        <script type="text/javascript">
            //<![CDATA[
            function openWin()
            {
                var oWnd = radopen("Dialog1.aspx", "RadWindow1");
            }

            function OnClientClose(oWnd, args)
            {
                //get the transferred arguments
                var arg = args.get_argument();
                if (arg)
                {
                    var cityName = arg.cityName;
                    var seldate = arg.selDate;
                    $get("order").innerHTML = "You chose to fly to <strong>" + cityName + "</strong> on <strong>" + seldate + "</strong>";
                }
            }
            //]]>
        </script>
        <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false"
            ReloadOnShow="true" runat="server" Skin="Sunset" EnableShadow="true">
            <Windows>
                <telerik:RadWindow ID="RadWindow1" runat="server" Behaviors="Close" OnClientClose="OnClientClose"
                    NavigateUrl="Dialog1.aspx">
                </telerik:RadWindow>
                <telerik:RadWindow ID="RadWindow2" runat="server" Width="650" Height="480" Modal="true"
                    NavigateUrl="Dialog2.aspx">
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
        <div id="offsetElement" class="bigModule" style="height: 400px; padding: 8px;">
            <p>
                Click the button to open the Travel Planner form in a RadWindow.
            </p>
            <button onclick="openWin(); return false;">
                Choose Destination and date</button>
            <div id="order" class="orderText">
                <!---->
            </div>
            <br />
            <br />
        </div>
        <qsf:Footer runat="server" ID="Footer1" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451