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

GetRadWindow is not defined on Activate

6 Answers 506 Views
Window
This is a migrated thread and some comments may be shown as answers.
Paul Mc
Top achievements
Rank 1
Paul Mc asked on 18 Jun 2009, 12:03 PM

Hi

We’re having problems with our GetRadWindow procedure when closing radwindows.

In the below example, we have a main navigation page (denoted by default.aspx), a page that is opened from default.aspx (denoted by window1.aspx) and a page that can be opened from window1.aspx (denoted by window2.aspx).

As a window is closed, we anticipate the activate event will fire of the remaining window, which it appears to if we close window 2 before window 1.  However, if we close window 1 first, window 2 reports that GetRadWindow is not defined in the Activate event.

I'm sure I'm doing something stupid, but I just can’t see what it is. Any help would be much appreciated.

Default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="CascadingWindows_Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <title></title>  
          
        <script language="JavaScript" src="Jscript.js" type="text/javascript"></script> 
    </head> 
      
    <body> 
        <form id="form1" runat="server">  
            <telerik:RadScriptManager ID="ScriptManager" runat="server"></telerik:RadScriptManager> 
            <telerik:RadWindowManager ID="WindowsManager" runat="server" DestroyOnClose="true" VisibleStatusbar="false"></telerik:RadWindowManager> 
            <input id="Button1" type="button" value="Open Window 1" onclick="WindowOpen('Window1.aspx')"  /> 
        </form> 
    </body> 
</html> 
 


Window1.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Window1.aspx.vb" Inherits="CascadingWindows_Window1" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <title></title>  
                  
        <script language="JavaScript" src="Jscript.js" type="text/javascript"></script> 
          
    </head> 
    <body> 
        <form id="form1" runat="server">  
            <h1>Window 1</h1> 
            <div> 
                <input id="Button1" type="button" value="Open Window 2" onclick="WindowOpen('Window2.aspx')"  /> 
            </div> 
        </form> 
    </body> 
</html> 

Window2.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Window2.aspx.vb" Inherits="CascadingWindows_Window2" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <title></title>  
                  
        <script language="JavaScript" src="Jscript.js" type="text/javascript"></script> 
    </head> 
    <body> 
        <form id="form1" runat="server">  
            <h1>Window 2</h1> 
        </form> 
    </body> 
</html> 
 


Jscript.js

function GetRadWindow() {  
    if (window.radWindow) return window.radWindow;  
    else if (window.frameElement != null && window.frameElement.radWindow) return window.frameElement.radWindow;  
    return null;  
}  
 
 
function WindowActivate(sender, eventArgs) {  
    var oRadWindow = GetRadWindow();  
     
    /* More code removed for this example */  
}  
 
 
function WindowOpen(windowUrl) {  
 
    var oRadWindow = GetRadWindow();  
    var oManager = null;  
 
    if (oRadWindow == null) { oManager = GetRadWindowManager(); }  
    else { oManager = oRadWindow.BrowserWindow.GetRadWindowManager(); }  
 
    if (oRadWindow == null) { oWnd = radopen(windowUrl, null); }  
    else { oWnd = oRadWindow.BrowserWindow.radopen(windowUrl, windowUrl);}  
 
    oWnd.add_activate(WindowActivate);  
 

 

6 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 19 Jun 2009, 01:37 PM
Hi Paul Mc,

I used the provided code and followed the described steps, but I was not able to reproduce any problems on my side. I would like to point that the code in the WindowActivate event may not work properly, because the GetRadWindow() function called in it may return 'null' value. Then, if you use the 'oRadWindow' object you will get an error. That function returns null in this case because default.aspx is not opened in a RadWindow object. Thuis function returns the RadWindow object that contains the page that contains the declaration of the GetRadWindow() function.

Once again, I was not able to reproduce the reported issue on my side and I need your further cooperation. Could you please rework the attached project in order to reproduce the issue, open a new support ticket and send it back? Once I have a better view over your setup I will do my best to provide a working solution.

Sincerely yours,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Paul Mc
Top achievements
Rank 1
answered on 19 Jun 2009, 02:10 PM
Hi Fiko

Thanks for coming back to me.

Your attached example does have the problem without me making any changes.  To reproduce the problem:

  1. Open the Default_VB.aspx page in a normal browser window.
  2. Click the "Open Window 1" button which should open a rad window
  3. On Window 1, click the "Open Window 2" button which should open window 2.
  4. Leaving Window 2 open, close window 1 using the cross in the top right hand corner.
  5. Now click window 2 to activate it.  At this point a javascript error is being reported which is "GetRadWindow is not defined".

Following your further concerns, I'm slight puzzled as to why GetRadWindow would even be fired for Default_VB.aspx as that page is not being opened in a RadWindow and therefore we are not assigning the OnActivate to the page?  Obviously, as far as the WindowOpen proc, we check to see if oRadWindow is null before using the variable to decide how we are going to open the window (i.e. where the Rad Manager is located).  Or am I misundstanding something?

Thanks again and I look forward to hearing from you.

Paul

0
Fiko
Telerik team
answered on 19 Jun 2009, 04:14 PM
Hi Paul,

I followed the steps and I was able to reproduce the problem. It occurs because you use the DestroyOnCloese="true" property in the RadWindowManager's declaration. This property causes the window objects to be destroyed after closing it. Respectively the functions declared on the content page(that is opened inside the destroyed window) are destroyed as well and this is causing the error. In your scenario I suggest you use the DestroyOnClose=false(it is false by default) property. Then you should not have the same problem.
If you need to reload the content page every time when the RadWindow is shown, then you can use the ReloadOnShow=true(it is false by default) property.

In reference to the GetRadWindow() function :
  1. First you open the default_Vb.aspx. On that page you have the following tag
    <script language="JavaScript" src="Jscript.js" type="text/javascript"></script> 
    it includes the GetRadWindow() function on that page(Default_Vb.aspx)
  2. When you open the first RadWindow you attach a handler to its activate event. That handler is on the Default_Vb page and calls the GetRadWindow() function.
  3. The problem is that when you activate the first RadWindow (that contains the Popup1_Vb.aspx page), the GetRadWindow() function is called on the default_Vb.aspx and it always returns 'null':
    function WindowActivate(sender, eventArgs) 
        // TELERIK : When this event is called from the first window, then the getRadWindow() will return 'null' 
        // because the default.aspx is not opened in a RadWindow object 
        var oRadWindow = GetRadWindow()
        /* More code removed for this example */ 

I hope this information helps.

All the best,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Paul Mc
Top achievements
Rank 1
answered on 23 Jul 2009, 01:14 PM
Hi Fiko

I'm sorry I have let this thread go cold.  I have been looking at other things and was kind of hoping that this problem would go away... which of course is hasnt!

I've now come back to it and been looking over your reply and I think I understand why this is happening.  However, I was wondering if there is any way to effectively tie the opening of the second window (window2.aspx) back to default.aspx, rather than window1.aspx as it is according to your description, so that when window1.aspx is closed, the functions that are tied to it for window2.aspx are not destroyed as well.

I've tried setting DestoryOnClose to false as you recommended and that seems to cause us more problems than it fixes.

Forgive me if this is completely the wrong of thinking.

Kind regards

Paul
0
Paul Mc
Top achievements
Rank 1
answered on 27 Jul 2009, 01:03 PM
Anybody?
0
Fiko
Telerik team
answered on 28 Jul 2009, 01:49 PM
Hi Paul Mc,

To be able to help I need to have a better view over your exact setup and logic. Please open a new support thread and send me a runnable project that I can examine locally and investigate the reason for the problem.

All the best,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Window
Asked by
Paul Mc
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Paul Mc
Top achievements
Rank 1
Share this question
or