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

GetRadWindowManager() always returns 'undefined' in May 2008 release

10 Answers 1289 Views
Window
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 27 May 2008, 05:22 AM
I'm trying to get a rad window to show that used to show ok in previous versions of telerik but now the GetRadWindowManager always returns 'undefined'.  Is this a backward compatability issue?

function

ShowWindow()
{
var omanager = GetRadWindowManager();
var ownd = omanager.getWindowByName("DialogWindow1");
ownd.show();
}
 

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<telerik:RadWindowManager id="Singleton" runat="server" ClientCallBackFunction="ResetPasswordWindowClosed" >

<windows>

<telerik:RadWindow id="DialogWindow1"

Modal = "true"

Runat="server"

Width="600px"

Height="250px"

Title="Reset Password"

NavigateUrl="~/Support/ResetPassword.aspx"

Skin="WebBlue"

VisibleStatusbar="false"

Behavior="Close"

>

</telerik:RadWindow>

</windows>

</telerik:RadWindowManager>


//and in code behind

public void OpenResetPasswordWindow()
{
literalInjectJavascript.Text = "<script type='text/javascript'> ShowWindow(); </script>";
}


I've tried numerous different examples from telerik site but whenever I call GetRadWindowManager() the result is always 'undefined'.

Your help is most appreciated as I've spent most of the day trying to get this working.
Thankyou

10 Answers, 1 is accepted

Sort by
0
Accepted
Svetlina Anati
Telerik team
answered on 27 May 2008, 04:21 PM
Hello Paul,

The controls in the RadControls for ASP.NET AJAX suite are built upon the MS AJAX framework and the framework itself creates its controls (including RadWindow) in the Sys.Application.add_init() method - you can check this for yourself by examining the HTML dump of a page with RadControls for ASP.NET AJAX included in it (or any other ASP.NET AJAX control).

That is why when you try to obtain a reference to the RadWindowManager its client object is still not created. To correctly reference it you should add a load handler as shown below:

 literalInjectJavascript.Text = "<script type='text/javascript'> Sys.Application.add_load(ShowWindow); </script>"

Another option is to execute your code with a small timeout.

For your convenience I am attaching your modified code.

Sincerely yours,

Svetlina
the Telerik team


Instantly find answers to your questions at the new Telerik Support Center
0
Paul
Top achievements
Rank 1
answered on 28 May 2008, 12:21 AM
Thankyou so much,  it's working now.  phew what a relief.
Thanks
0
cy19
Top achievements
Rank 1
answered on 25 Jun 2008, 09:53 PM
I'm doing something similar and getting a similar error (GetRadWindowManager always returns 'undefined').

Mine's a bit different though, in that I'm using it on the MasterPage, calling it from a Menu.  Here's where it's called:

<telerik:RadMenuItem runat="server" Text="Bookmarks">
   <Items>
      <telerik:RadMenuItem runat="server" Text="Bookmark Page" NavigateUrl="javascript:Bookmark();">
      </telerik:RadMenuItem>
   </Items>
</telerik:RadMenuItem>


Here's the Window Manager:

<telerik:RadWindowManager ID="windowMgr" runat="server" ReloadOnShow="true">
        <Windows>
            <telerik:RadWindow 
                ReloadOnShow="true"
                NavigateUrl="~/Bookmarks/AddBookmark.aspx"
                ClientCallBackFunction="TriggerEvent"   
                runat="server"
                Height="400"
                Width="400"
                ID="BookmarkWindow"  
                Behavior="Close,Resize,Move"
                VisibleStatusbar="false" IconUrl="../favicon.ico" Modal="true">
            </telerik:RadWindow>
        </Windows>
</telerik:RadWindowManager>


And the javascript:

function Bookmark()
{
    var omanager = GetRadWindowManager();
   
    alert(omanager);  //Always shows undefined
    var ownd = omanager.getWindowByName("BookmarkWindow");
    ownd.show();
}

So with what I have to work with, I can't really do an onclick and add in that add_load function since I can't add an onclick to the RadMenuItem.  I tried to put it right into it like this:

<telerik:RadMenuItem runat="server" Text="Bookmark Page" NavigateUrl="javascript:Sys.Application.add_load(Bookmark());">

But that doesn't work either.

Any ideas for me?

Thank you,

Chris
0
Svetlina Anati
Telerik team
answered on 26 Jun 2008, 10:10 AM
Hello cy19,

I tested your code and it works as expected on my side, the RadWindowManager object is referenced and a RadWindow opens. Furthermore, in your particular case you do not have to add a load handler, because when you click on the menu item you actually do not perform a postback.

Please, find my test project attached and test it on your side.

In case you still experience problems, prepare a new, fully runnable project or modify mine in order to reproduce the described behavior, open a new support ticket and send it to me. Once I receive it, I will locate the problem and I will modify it in order to meet your requirements.


Greetings,
Svetlina
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mark
Top achievements
Rank 1
answered on 25 Jul 2008, 10:48 AM
Hi,

I think I am having a similar problem.  I am trying to load the radwindow as soon as a page opens on first load.  To do this I have a openWin JS function used to call radopen to open the radwindow.  I have tried 2 methods to call my JS function but I get the undefined method with both.  I the page load I have tried:

 

ScriptManager

.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW_C", "openWin('QuoteCompare2.aspx',0);", true);

AND

InjectScript.Text =

"<script type='text/javascript'> Sys.Application.add_load(openWin('QuoteCompare2.aspx',0));</script>";


Inside my JS openWin function I also get undefined for the following:

var oManager = GetRadWindowManager();

alert(oManager);

Can anyone help.

Thanks in advance.

0
Mark
Top achievements
Rank 1
answered on 25 Jul 2008, 11:09 AM
I have fixed this with the following by including a timeout.  I was under the impression I shouldnt need to do this though and using the add_load should work!

ScriptManager

.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW_C", @"window.setTimeout(""openWin('QuoteCompare2.aspx',1)"",500);", true);

0
eugene petrov
Top achievements
Rank 1
answered on 19 Oct 2008, 10:55 PM
Hi Svetlina,

I had a similar problem and your "Sys.Application.add_load(ShowWindow);" suggestion helped me to resolve it. Thanks heaps!
0
Matthias Heinrich
Top achievements
Rank 2
answered on 11 Oct 2011, 04:41 PM
Thx Svetlina and Eugene :)

The Timeout like Eugene describes is working for me, too!
0
TuanTH
Top achievements
Rank 2
answered on 11 Apr 2012, 11:59 AM
Thanks for ideas, i fixed this bug
0
Marin Bratanov
Telerik team
answered on 11 Apr 2012, 01:54 PM
Hello,

I'd just like to point out that this is not a bug, but the general way the frameworks is designed and should be used. As for previous posts regarding the need for timeout with the Sys.Application.add_load() method - it only takes the name of the function to be executed, not an entire function, more details and an example of using the approach can be found in this help article: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html.


Greetings,
Marin
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.
Tags
Window
Asked by
Paul
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Paul
Top achievements
Rank 1
cy19
Top achievements
Rank 1
Mark
Top achievements
Rank 1
eugene petrov
Top achievements
Rank 1
Matthias Heinrich
Top achievements
Rank 2
TuanTH
Top achievements
Rank 2
Marin Bratanov
Telerik team
Share this question
or