Joel 10/10/2011 1:06:17 PM

Telerik - RadWindowManager - Code example for returning text from a RadWindow

This is a complete code example for returning code from a Telerik RadWindow.

The code is copied from the Demo code, but is greatly simplified to more clearly show what is needed to pop up a RadWindow and then to return data from it.

Note that the code runs inside a Master Page, and depends on that page having a RadScriptManager in it already.

There are three pieces of code.

The main page:

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="ReturningValuesFromADialog.aspx.vb" Inherits="RadWindow_ReturningValuesFromADialog" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function openWin() {
            var oWnd = radopen("Dialog.aspx", "RadWindow1");
        function OnClientClose(oWnd, args) {
            //get the transferred arguments
            var arg = args.get_argument();
            if (arg) {
                var Input = arg.Input;
                document.getElementById("ContentPlaceHolder1_txtTextFromDialog").value = "Your input was " + Input;
    <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false"
        ReloadOnShow="true" runat="server" Skin="Sunset" EnableShadow="true">
            <telerik:RadWindow ID="RadWindow1" runat="server" Behaviors="Close" OnClientClose="OnClientClose"
    <button onclick="openWin(); return false;">Open Dialog</button><br />
    <asp:TextBox ID="txtTextFromDialog" runat="server"></asp:TextBox>


The Dialog. This page should be named 'Dialog.aspx'

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Dialog.aspx.vb" Inherits="RadWindow_Dialog" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<head id="Head1" runat="server">
    <title>Window Title</title>
<body >
    <form id="Form2" method="post" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <script type="text/javascript">
            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow;
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                return oWindow;
            function returnToParent() {
                //create the argument that will be returned to the parent page
                var oArg = new Object();
                //get the input text
                oArg.Input = document.getElementById("txtInput").value;
                //get a reference to the current RadWindow
                var oWnd = GetRadWindow();
                //Close the RadWindow and send the argument to the parent page
                if (oArg.Input ) {
                else {
                    alert("Please fill in field");
        <asp:TextBox ID="txtInput" runat="server"></asp:TextBox>
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" />

The code behind for the dialog

Partial Class RadWindow_Dialog
    Inherits System.Web.UI.Page
    Protected Sub RadWindow_Dialog_Load(ByVal sender As ObjectByVal e As System.EventArgsHandles Me.Load
        Me.btnSubmit.Attributes.Add("onclick""returnToParent(); return false;")
    End Sub
End Class