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

Opening a window from a RadWindowManager Template

5 Answers 145 Views
Window
This is a migrated thread and some comments may be shown as answers.
terrysmith
Top achievements
Rank 1
terrysmith asked on 18 Jun 2008, 10:48 PM
We have started experiencing a very frequent problem with our dialog windows resulting in a "null is not null" Javascript error.  It has started happening since the Q1 update. We have a modal window template defined on the MasterPage like this:

<telerik:RadWindowManager ID="ieRadWindowManager" runat="server"
    <Windows> 
        <telerik:RadWindow ID="ModalWindow" Modal="true" Behaviors="Close,Resize,Move" VisibleOnPageLoad="false" VisibleStatusbar="false" ReloadOnShow="true" ShowContentDuringLoad="false" runat="server" /> 
    </Windows> 
</telerik:RadWindowManager> 

This is the only RadWindowManager defined in our application. Various dialogs use this same template and are launched with code like this:

function showChartOptions(url) 
    var manager = GetRadWindowManager(); 
    var modalWindow = manager.getWindowByName("ModalWindow"); 
    modalWindow.add_close(OnChartOptionsClose); 
    modalWindow.setSize(600,450); 
    modalWindow.setUrl(url); 
    modalWindow.show(); 

The problem is that getWindowByName frequently returns NULL, but not always. We can restart IIS and it will work again for a little while, but then on another dialog window using the same ModalWindow template the call will fail and result in a "null is not null" Javascript error.

What would be causing the ModalWindow template to not be initialized or present?

As a "best practices" question, should I even be doing it this way to begin with? Does the modal window template introduce overhead on every page in the application that is not always needed? I like having the settings defined once that are used everywhere, but if it's better to do a "open" and create a new window every time we need it then I can do it that way.

Thanks,
Terry

5 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 19 Jun 2008, 03:01 PM
Hello Terry,

In general, RadWindow for ASP.NET AJAX can be accessed by using the standard $find() method
($find("<%= RadWindow1.ClientID %>")) - in the new version there is no need to have a RadWindowManager in the page to open RadWindows. You can declare them in the aspx and access them by $find.

The part of your code seems fine, however I believe that the problem in this case is that you do not remove the closing handler once you execute the closing function. Note that when closed, the RadWindow object is not destroyed. I would suggest to remove the closing handler and to see how your application behave.
e.g.:

function OnChartOptionsClose(sender, args)
{
//Other code.....
//Add this to remove handler
   sender.remove_close(OnChartOptionsClose)
}


I hope this helps. If you still experience problems, it will be best to open a support ticket and to send us a small sample application which reproduces them. We will check it and do our best to help.



Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
terrysmith
Top achievements
Rank 1
answered on 23 Jun 2008, 06:22 PM
We are still experiencing the "null is not null" Javascript error. I removed the ModalWindow template as defined further above in this thread and every dialog now has its own RadWindow declaration. The find$ method randomly returns null.

I added the sender.remove_close calls as suggested however I don't believe that is related to this issue. The issue is not with repeatedly opening the same RadWindow on a page but with opening it the first time. I have a link on a page that displays a RadWindow and sometimes the find$ call will work and sometimes it does not. I can simply refresh the whole page and it may start working again. We have several instances of this scenario.

Is there anything else you can recommend that I try or look into? We have a very important product demo of our application on Friday and this is our #1 problem.

Thank you,
Terry
0
Georgi Tunev
Telerik team
answered on 24 Jun 2008, 11:49 AM
Hi Terry,

In this case it will be best to open a support ticket and send us the following:
  1. Small sample project where the problem can be reproduced.
  2. Step-by-step instructions that reproduce the problem every time
  3. Detailed description of the desired behavior.
We will check it and do our best to help right away.


Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
instigator
Top achievements
Rank 1
answered on 24 Jul 2008, 08:02 PM
I have a page that is heavily ajaxed that uses the same radwindow. Each time the window is opened a new OnClientClose method is added using add_close. However, each time the window is close, ALL the methods added using add_close try to fire. Is there a way to set the OnClientClose to null in javascript? before I do an add_close? Guaranteeing that any methods are removed from the OnClientClose before adding a new one?

Thanks
0
Georgi Tunev
Telerik team
answered on 28 Jul 2008, 06:46 AM
Hello instigator,

In ASP.NET AJAX, you can use the add_eventname and remove_eventname methods to add/remove event handlers. For example:

<form id="form1" runat="server"
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
    <script type="text/javascript"
        function openWin() 
        { 
            var oWnd = radopen("http://www.google.com", "RadWindow1");  
            oWnd.add_close(ClosingFn);  
        } 
         
        function ClosingFn(oWnd) 
        { 
            alert(oWnd + " was closed");  
        } 
         
        function removeClose() 
        { 
            var oWnd = $find("RadWindow1");  
            if(oWnd) 
            { 
                oWnd.remove_close(ClosingFn);  
            } 
            else 
            { 
                alert("RadWindow not found"); 
            } 
        } 
         
    </script> 
    <telerik:RadWindowManager  
        DestroyOnClose="true"  
        ID="RadWindowManager1"  
        runat="server"
    </telerik:RadWindowManager> 
    <button onclick="openWin(); return false;">open and set</button> 
    <br /><br /> 
    <button onclick="removeClose(); return false;">remove OnClientClose</button> 
</form> 


I hope this helps. More information on the subject is available in many ASP.NET AJAX resources on the Net - for example you can check this article:
http://dotnetslackers.com/articles/ajax/RaisingAndHandlingEventsWithASPNETAjax.aspx

Greetings,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
terrysmith
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
terrysmith
Top achievements
Rank 1
instigator
Top achievements
Rank 1
Share this question
or