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

Refresh the main page on close of popup window

3 Answers 1749 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
CPK
Top achievements
Rank 1
CPK asked on 28 Sep 2016, 06:31 AM

I am opening the popup window with the below code from Server side

var url = string.Format("../UserPopup.aspx?user_Ids={0}&fromDate={1}&toDate={2}", user_Ids, fromDate, toDate);
string script = string.Format("function f(){{openDialog('{0}', {1}, {2}, {3});Sys.Application.remove_load(f);}}Sys.Application.add_load(f);",
                                     url,
                                     "true",   
                                     1000,
                                     300);
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "someKey", script, true)

Below is the code for closing the popup window from javascript. The below code is not working.

function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow)
                oWindow = window.radWindow;
            else if (window.frameElement.radWindow)
                oWindow = window.frameElement.radWindow;
            return oWindow;
        }
 
function Close() {
var result = window.confirm("Are you sure you want to close the window!");
if (result == true) {
    var oWindow = GetRadWindow();
    oWindow.argument = null;
    oWindow.onunload = refreshParent;
    oWindow.close();
    return false;
    }
 }
 
 function refreshParent() {
     window.opener.location.reload();
 }

How can I close the popup window from client side and refresh the parent page?

 

FYI: I am using RadWindow as popup for this.

3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 28 Sep 2016, 11:46 AM

Hi,

You should use the OnClientClose event in the main page: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/client-side-programming/events/onclientclose. The article also shows how to properly pass an argument to the event handler.

 

Regards,

Marin Bratanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
CPK
Top achievements
Rank 1
answered on 28 Sep 2016, 12:45 PM

I am getting the below error when I placed the main page code in debug mode

An exception of type 'System.ApplicationException' occurred in System.Web.dll but was not handled in user code

Additional information: Response.Redirect cannot be called in a Page callback.

Also, I want it to open only on clicking of button from Server Side. Now it is opening the page on open of main page.
0
Marin Bratanov
Telerik team
answered on 29 Sep 2016, 06:58 AM

Hello,

This error indicates that the Response.Redirect() method was called during partial page rendering which is not supported by the MS AJAX framework. You can find a solution through RadAjaxManager here: http://docs.telerik.com/devtools/aspnet-ajax/controls/ajaxmanager/how-to/redirecting-to-another-page. Or you can just register a script yourself.

As for the RadWindow reopening—you need to ensure the code that opens it is not called again after the postback and that its VisibleOnPageLoad property is not set to true: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/troubleshooting/opening-from-the-server.

Regards,

Marin Bratanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
General Discussions
Asked by
CPK
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
CPK
Top achievements
Rank 1
Share this question
or