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

11 posts, 1 answers
  1. Paul
    Paul avatar
    12 posts
    Member since:
    May 2008

    Posted 27 May 2008 Link to this post

    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

  2. Answer
    Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 27 May 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Paul
    Paul avatar
    12 posts
    Member since:
    May 2008

    Posted 27 May 2008 Link to this post

    Thankyou so much,  it's working now.  phew what a relief.
    Thanks
  5. cy19
    cy19 avatar
    4 posts
    Member since:
    Aug 2007

    Posted 25 Jun 2008 Link to this post

    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
  6. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 26 Jun 2008 Link to this post

    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
  7. Mark
    Mark avatar
    13 posts
    Member since:
    Apr 2008

    Posted 25 Jul 2008 Link to this post

    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.

  8. Mark
    Mark avatar
    13 posts
    Member since:
    Apr 2008

    Posted 25 Jul 2008 Link to this post

    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);

  9. eugene petrov
    eugene petrov avatar
    1 posts
    Member since:
    Apr 2008

    Posted 19 Oct 2008 Link to this post

    Hi Svetlina,

    I had a similar problem and your "Sys.Application.add_load(ShowWindow);" suggestion helped me to resolve it. Thanks heaps!
  10. Matthias Heinrich
    Matthias Heinrich avatar
    6 posts
    Member since:
    Nov 2009

    Posted 11 Oct 2011 Link to this post

    Thx Svetlina and Eugene :)

    The Timeout like Eugene describes is working for me, too!
  11. TuanTH
    TuanTH avatar
    4 posts
    Member since:
    Mar 2010

    Posted 11 Apr 2012 Link to this post

    Thanks for ideas, i fixed this bug
  12. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3596 posts

    Posted 11 Apr 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017