This is a migrated thread and some comments may be shown as answers.

close child and parent popup and refresh grid on grandparent page on click of button on child popup

1 Answer 107 Views
Window
This is a migrated thread and some comments may be shown as answers.
kal
Top achievements
Rank 1
kal asked on 21 May 2012, 09:17 AM

Hi

I am using telrik radopen function to open the popups. I have a situation in which child popup opens from parent popup which opens from grandparent .aspx page.

Grandparent (.aspx page) -> popup (parent) -> popup(child)

I want to close the parent popup and child popup on click of a button on child popup. I tried using 

GetRadWindow().BrowserWindow.BrowserWindow.Close() // this one and variations of this errored !

GetRadWindow().BrowserWindow.close(); // this did not errored but didn't close parent window
GetRadWindow().Close(); // this closes only child window - when invoked from button click on child window

I read the question Is it possible to close parent window from child (Javascript)?

If in case it is not possible to close the parent popup from child popup is there a workaround so that I can simulate the behavior of 'submit button click' on child control can close child and parent popup and refresh the grid on the grandparent .aspx page?

May be redirect can help. In that case how do I do that?
Any suggestions.

Thanks
Kuldip

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 23 May 2012, 04:20 PM
Hi Kuldip,

The important bit is to get proper references to the RadWindow controls so that you can use their client-side API to control them. For getting a reference to a RadWindow from within the page loaded inside you can use this function:
function GetRadWindow()
{
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

Then declare in each page a function to close the RadWIndow, e.g.:
function closeMeFromInside()
{
    GetRadWindow().close(); 
}

and this is the function you would need to call to close each instance:
in the popup (child)
function closeAll()
{
    closeMeFromInside();//closes the current (last) RadWindow
    GetRadWindow().BrowserWindow.closeMeFromInside();//calls the same method from the first popup so that it closes
}

And to refresh the grid on the main page you can hook to the OnClientClose event of the first RadWindow and invoke a postback, an AJAX request or call window.location.reload() to refresh the page.

Regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
kal
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or