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

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

6 Answers 114 Views
Window
This is a migrated thread and some comments may be shown as answers.
Darren Ratcliffe
Top achievements
Rank 1
Darren Ratcliffe asked on 21 Oct 2008, 10:45 AM
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            

6 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 21 Oct 2008, 12:24 PM
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.
0
Darren Ratcliffe
Top achievements
Rank 1
answered on 23 Oct 2008, 11:17 AM
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:

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

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

Best regards

Darren        
0
Georgi Tunev
Telerik team
answered on 23 Oct 2008, 11:48 AM
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.
0
Darren Ratcliffe
Top achievements
Rank 1
answered on 24 Oct 2008, 07:52 AM
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
0
Tervel
Telerik team
answered on 24 Oct 2008, 08:00 AM
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.
0
Darren Ratcliffe
Top achievements
Rank 1
answered on 12 Nov 2008, 01:42 PM
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 :)    
Tags
Window
Asked by
Darren Ratcliffe
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Darren Ratcliffe
Top achievements
Rank 1
Tervel
Telerik team
Share this question
or