Can't open new window with JavaScript (Q1 2008)

7 posts, 0 answers
  1. Darren Ratcliffe
    Darren Ratcliffe avatar
    21 posts
    Member since:
    Aug 2007

    Posted 21 Oct 2008 Link to this post

    Hi all

    I have read through a couple of threads on this but can't find a resolution and it's really frustrating me, so I'm hoping for some help.

    I have tried to do this:

     

    var manager = GetRadWindowManager();
    var window1 = manager.GetWindowByName("oWinItem");
    window1.show();

     

    And I have tried to do this:

    var

     

    oWnd = $find("<%= oWinItem.ClientID %>");
    oWnd.show();

     

    But I am getting this blased undefined error.

    I read through the post below, which discusses using a delay, but in all honesty it doesn't really make any sense to me as I haven't used a script manager before.

    https://www.telerik.com/community/forums/thread/b311D-beacgk.aspx

    I'm really hoping somebody can help!!

    Many thanks

    Darren            
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 21 Oct 2008 Link to this post

    Hello Darren,

    Could you please provide some more information on what exactly you want to achieve? A basic setup like the one below is working fine (see attached movie), so I guess that the problem is somewhere else.

    <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server"
        </asp:ScriptManager> 
        <script type="text/javascript"
            function openWin() 
            { 
                var manager = GetRadWindowManager(); 
                var window1 = manager.GetWindowByName("oWinItem"); 
                window1.show();  
            } 
         
        </script> 
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
            <Windows> 
                <telerik:RadWindow ID="oWinItem" runat="server" NavigateUrl="http://www.google.com"
                </telerik:RadWindow> 
            </Windows> 
        </telerik:RadWindowManager> 
        <button onclick="openWin(); return false;"
            test</button> 
    </form> 


    Greetings,
    Georgi Tunev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Darren Ratcliffe
    Darren Ratcliffe avatar
    21 posts
    Member since:
    Aug 2007

    Posted 23 Oct 2008 Link to this post

    Hi Georgi

    If you visit this url, you will see exactly what I mean:

    http://cardealeroldham.autofantastic.co.uk/content/information-pages/part-exchange.aspx?showpx=1

    You will notice you get a javascript error that says:

    Line: 57
    Char: 16
    Error: 'undefined' is null or not an object

    The javascript is called by being writtten in (dynamically) just above the closing body tag of the page and reads:

    1 function LaunchPXWindow()  
    2             {  
    3                var manager = GetRadWindowManager();  
    4                var window1 = manager.GetWindowByName("oWinItem");  
    5                window1.SetSize(550,450);  
    6                window1.SetTitle("Part Exchange");  
    7                window1.SetUrl("http://www.autofantastic.co.uk/apps/staticvaluation/default.aspx?s=" + iSiteID + "v=" + iVehicleID);  
    8                window1.show();  
    9             } 

    Line 57 in my source code is line 4 in the snippet above.

    Best regards

    Darren        
  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 23 Oct 2008 Link to this post

    Hello Darren Ratcliffe,

    In your page's source code I see the following line which is placed outside of the form:
     <script type="text/javascript">LaunchPXWindow();</script>
    If I understand your logic correctly, you want to execute this function right after the page is loaded - note however that in ASP.NET AJAX, all ASP.NET AJAX controls (including ours) are created after the page has been loaded. I assume that the problem here is that when you initially try to get a reference to the RadWindowManager, the control is still not fully rendered on the page and that is why the error arise.
    Try outputting the following code instead - it uses the ASP.NET AJAX's pageLoad() function:
    <script type="text/javascript"
    function pageLoad() 
        LaunchPXWindow(); 
    </script> 


    Best wishes,
    Georgi Tunev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Darren Ratcliffe
    Darren Ratcliffe avatar
    21 posts
    Member since:
    Aug 2007

    Posted 24 Oct 2008 Link to this post

    Thanks Georgi, I'll give that a try but it sounds very feasible - working this way has worked for me with previous releases of RadControls - so I hand't considered it.

    Will pageLoad() execute automatically, or do I have have to specify it somewhere?   Also, do I put this function at the top or bottom of my page... or does it not make a difference?

    Many thanks for your help

    Darren
  6. Tervel
    Admin
    Tervel avatar
    1337 posts

    Posted 24 Oct 2008 Link to this post

    Hi Darren,

    The function pageLoad is called automatically by the MS AJAX client framework. It does not matter where you put in on the page either.


    Greetings,
    Tervel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Darren Ratcliffe
    Darren Ratcliffe avatar
    21 posts
    Member since:
    Aug 2007

    Posted 12 Nov 2008 Link to this post

    Took me a while to get back to looking at this but it works a treat - I've learned a fantastic little trick in ASP.NET

    Thanks :)    
Back to Top