Anyname Donotcare Anyname Donotcare - 1 year ago 214
ASP.NET (C#) Question

How to close the radwindow on serverside and refresh the parent page

I want to close the RadWindow and refresh the parent : how to do this server side :

I have the following case:

Two pages say :

parent.aspx :

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableViewState ="false">

and parent.cs

protected void OpenNewWindow(string url, int width, int height,int mode)
RadWindow newWindow = new RadWindow();
newWindow.NavigateUrl = url;
newWindow.VisibleOnPageLoad = true;
newWindow.KeepInScreenBounds = true;
if (width > 0)
newWindow.Width = width;

if (height > 0)
newWindow.Height = height;
newWindow.VisibleStatusbar = false;
if (mode == 0)
newWindow.DestroyOnClose = true;
newWindow.InitialBehaviors = WindowBehaviors.Maximize;

i call this method in the rowcommand of some gridview on my parentpage :

like this :

OpenNewWindow("child.aspx", 0, 0,0);

Now i want on the server side click event of some button on the
page to close the rad window and refresh the parent one how to do this ??

Win Win
Answer Source

As you said, you want to close from code behind. So you can render Page.ClientScript.RegisterClientScriptBlock(GetType(), "CloseScript", "refreshParentPage()", true); from code behind to refresh the parent.

Just add the following code and script in Child Page. No code is needed in parent page.

    function getRadWindow() {
        var oWindow = null;
        if (window.radWindow)
            oWindow = window.radWindow;
        else if (window.frameElement.radWindow)
            oWindow = window.frameElement.radWindow;
        return oWindow;

    // Reload parent page
    function refreshParentPage() {

<asp:Button runat="server" Text="Close" ID="CloseButton" 

protected void CloseButton_Click(object sender, EventArgs e)
        "CloseScript", "refreshParentPage()", true);


// Redirect page page to url
function redirectParentPage(url) {
    getRadWindow().BrowserWindow.document.location.href = url;

// Code behind
"CloseScript", "redirectParentPage('Parent.aspx')", true);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download