Trouble closing window opened in another window

2 posts, 0 answers
  1. Dana Cobb
    Dana Cobb avatar
    46 posts
    Member since:
    Mar 2007

    Posted 04 Nov 2012 Link to this post

    I have an form that opens a radwindow which has a navigateUrl of another form. I will call this "window1". Next I want to open a second window from window 1, called "window2". All this works great. My problem is that I want to close "window2" without closing window1 ! I have tried numerous examples from the forum, but cannot seem to get it working. When it does anything at all it closes both window1 and window2...Now for some code that I am using...
    Code that opens window1:
    Dim script As String = "function f(){$find(""" + Me.daypopupwindow.ClientID + """).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, True)

    code that opens window2:
    function openAddWindow() {              
                      var oBrowserWnd = getRadWindow().BrowserWindow;
                    setTimeout(function () {
                        oBrowserWnd.radopen(null, "jobpopupwindow");
                    }, 0);

    Currently I am trying to close window2 with an html button calling a javascript function, but ideally it would be called from the code-behind.
    If I use this function it closes both windows:
    function closeActiveWindow() {
                    var oWin = getParentRadWindow();
    If I use this code, I get a "GetRadWindowManager()undefined" error
    function closeThisWindow() {
                   var omanager = GetRadWindowManager();
                   var ownd = omanager.getWindowByName("jobpopupwindow");

    Please help. I have tried so many things. It seems that geting a reference to the RadWindowManager on the first main page, then referencing a particular window and then calling close makes the most "sense", but I can't seem to get the reference to the manager from window2.


  2. Marin Bratanov
    Marin Bratanov avatar
    3907 posts

    Posted 06 Nov 2012 Link to this post

    Hello Dana,

    Closing a RadWindow from the page loaded inside is shown in this online demo: Take a look at the second one that loads a page and at the page itself - Dialog1.aspx. It shows the two JavaScript functions that close it upon a button click. You can use the same approach and call the function from the code-behind instead: (you would not need the Sys.Application.Load event in this case).

    I am not sure what your getParentRadWindow() function does, but if you want to close it through its parent manager you can use its API - call a function on the main page (, get a reference to the manager and use its own API ( - getWindowByName() and then close() it. What it seems is that right now you call the closeAll() method of the RadWIndowManager or perform a postback that disposes the RadWindows.

    All the best,
    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.
Back to Top