Closing Parent Window From Child Window

4 posts, 0 answers
  1. Sunil
    Sunil avatar
    3 posts
    Member since:
    Jun 2013

    Posted 10 Jun 2015 Link to this post

    Hello,

     Here's my scenario:

    1.  I have 3 pages.  The first page (let's call it MainPage.aspx) opens a RadWindow1.  RadWindow1 opens RadWindow2

    2.  In RadWindow2, some processing is done, and after the processing, from the code behind in RadWindow2, I want to close RadWindow1.  However, I want to keep RadWindow2.

    3.  On loading RadWindow1 from MainPage.aspx, I want to redirect the main page to a different aspx page.

     

     

     This is the current code:

    Code in MainPage.aspx That Opens RadWindow1 (ID = OpenTok)

    ==================================================

     ASPX

    =====

     <telerik:RadWindowManager runat="server" ID="RadWindowManager1">
            <Windows>
                <telerik:RadWindow ID="openTok"  NavigateUrl="OpenTokWindow.aspx" Header="Loading Settings ..." VisibleStatusbar ="false" VisibleOnPageLoad="false" Modal="false" OffsetElementID="main" InitialBehaviors="Maximize" runat="server" />
            </Windows>
        </telerik:RadWindowManager>

     JavaScript

    ========

    GetRadWindowManager().open(url, "openTok");

     

    Code in RadWindow1 That Opens RadWindow2 (ID = cogTest)

    ================================================== 

    ASPX

    ===== 

    <telerik:RadWindowManager runat="server" ID="RadWindowManager1">
            <Windows>
                <telerik:RadWindow ID="cogTest" Skin="Sunset" NavigateUrl="JSCognitiveAssessment.aspx" VisibleOnPageLoad="false"  Header="Cognitive Assessment" VisibleStatusbar="false" Modal="false" OffsetElementID="main" InitialBehaviors="Maximize" runat="server" />
            </Windows>
        </telerik:RadWindowManager>

     

    JavaScript

    ========

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

     

    var oBrowserWnd = GetRadWindow().BrowserWindow;
          oBrowserWnd.hide();

            
          function closeWin() {
              oBrowserWnd.close();
          }

     

     GetRadWindowManager().open(null, "cogTest");

     

    Closing the RadWindow1 from RadWindow2 code behind

    ============================================

    string script = "function f(){closeWin(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true); 

     

    Thank you for any information.

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 10 Jun 2015 Link to this post

    Hi Sunil,

    You need to call a function on the parent page that will get a reference to, and close, the first dialog: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/how-to/calling-functions-in-windows. The following article will explain how to get these references and how to use the control API: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/client-side-programming/overview. You may also find useful the following code library sample: http://www.telerik.com/support/code-library/creating-parent-child-relationships-between-radwindows-and-passing-data-between-them. It shows how you can have a reference to the first dialog within the second so you can modify it (e.g., close() it).

    As for redirecting the main page to another page when you open a RadWindow - you can use the OnClientShow event for that (http://docs.telerik.com/devtools/aspnet-ajax/controls/window/client-side-programming/events/onclientshow), but redirecting the main page will dispose the RadWindow.

    Regards,

    Marin Bratanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sunil
    Sunil avatar
    3 posts
    Member since:
    Jun 2013

    Posted 10 Jun 2015 in reply to Marin Bratanov Link to this post

    Marin,

    Thank you for your response.  If you look through my code, you will see that I have already tried doing this.  After your response, I read through the articles and tried other ways without success.

    I am unable to close the RadWindow1 from RadWindow2 code behind. 

    In addition, I am unable to re-direct the MainPage.aspx when RadWindow1 is launched from the main page.  I am not sure what you mean by "main page will dispose the Radwindow".

     

    Can you please show me an example based on my code I posted?

    Sunil

     

  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 11 Jun 2015 Link to this post

    Hi Sunil,

    As an exception, I have prepared a sample that shows one way to handle this scenario, which is based on the articles I linked above.

    As for redirecting the page when a RadWindow opens - I am attaching another sample that very clearly shows what will happen.

    Regards,

    Marin Bratanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top