Telerik UI for ASP.NET AJAX

By obtaining a reference to a RadWindow component, you can call any function that is defined in that windows content window. Just use the contentWindow property to reference the Content Window of the page loaded inside the RadWindow.

The example below shows one way to get a reference to the RadWindow with server ID RadWindow1. This approach may vary according to the scenario.

You can also see how you can pass information along to the other function. Passing an argument is not necessary, but it is an easy way to transfer information between different pages. Another approach to pass data to and from a RadWindow is shown in this help article.

CopyJavaScript
//CallFn shows how to call a predefined function
// in an opened RadWindow. A javascript function named
// CalledFn() must exist in RadWindow1's content
function CallFn()
{
    var oWnd = GetRadWindowManager().getWindowByName("RadWindow1");
    var myData = "some information";
    oWnd.get_contentFrame().contentWindow.CalledFn(myData);
}

//in the page where CalledFn resides you can consume this information, e.g.:
function CalledFn(data)
{
    alert(data);
}

Using this technique lets you call functions in a RadWindow's parent window or in a sibling window:

CopyJavaScript
//Note: the following 2 examples require
// the GetRadWindow() function to exist on the page.
// It is needed to get a reference to the RadWindow wrapper
function GetRadWindow()
{
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

// CallFnOnParent shows how to call a function
// in the parent page. A javascript function named CalledFn
// must exist in the parent page.
function CallFnOnParent()
{
    GetRadWindow().BrowserWindow.CalledFn();
}

// CallFn illustrates how to call a function in one RadWindow
// from another.
function CallFn()
{
    //Get a reference to the parent page (Default.aspx)       
    var oWnd = GetRadWindow();
    //get a reference to the second RadWindow       
    var dialogB = oWnd.get_windowManager().getWindowByName("RadWindow1");
    // by using get_contentFrame, call the predefined function
    dialogB.get_contentFrame().contentWindow.CalledFn();
}             

The approach from the first code snippet can be used in a similar way to pass data to the functions you call. Getting a reference to the sibling RadWindow may vary with the scenario (e.g. $find() can be used, a reference can be previously stored in a global variable, etc.).

See Also