Refresh the main page on close of popup window

4 posts, 0 answers
  1. CPK
    CPK avatar
    4 posts
    Member since:
    Aug 2016

    Posted 28 Sep Link to this post

    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.

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3596 posts

    Posted 28 Sep Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. CPK
    CPK avatar
    4 posts
    Member since:
    Aug 2016

    Posted 28 Sep in reply to Marin Bratanov Link to this post

    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.
  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3596 posts

    Posted 29 Sep Link to this post

    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.
Back to Top