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

RadWindow not found on page redirect

6 Answers 91 Views
Window
This is a migrated thread and some comments may be shown as answers.
mc2000
Top achievements
Rank 1
mc2000 asked on 21 Sep 2010, 03:20 AM

Hello:

I have a Website that inherits a .master page. The master page contains a RadWindow and a JavaScript method to show the RadWindow:

<telerik:RadWindow ID="Window1" runat="server" Modal="True" VisibleOnPageLoad="false" EnableShadow="true"
     Behaviors="Close" ReloadOnShow="true" AutoSize="false" Height="600" Width="800">
     <ContentTemplate>
         <asp:UpdatePanel ID="Window1UpdatePanel" runat="server" UpdateMode="Always">
         <ContentTemplate>
         </ContentTemplate>
         </asp:UpdatePanel>
     </ContentTemplate>
 </telerik:RadWindow>
function OpenModalWindow() {
    var oWnd = null;
    oWnd = $find("<%=Window1.ClientID%>"); }
    oWnd.Show();
}

One of my user controls does a response.redirect and loads a user control dynamically. The user controls Load event executes the JavaScript code from server side, which is supposed to show the window. It throws an error saying that oWnd is null (granted the JavaScript code and the modal are on the same master page). If I do a document.getElementById it returns an actual result (but tells me that .Show is an invalid method). So the object seems to exist. I know it's a shot in the dark but does anyone have any suggestions? On controls where the page is NOT redirecting it seems to work fine...thanks!

6 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 21 Sep 2010, 07:17 AM
Hi mc2000,

How do you call the JS code from the server? A problem like the one that you describe, usually occurs when the call to the RadWindowManager is made before the RadWindowManager is fully rendered on the page. Note that in ASP.NET AJAX, all AJAX controls (including ours) are rendered not when the page is loaded but on a later stage - Sys.Application.Load().
I would suggest to check this blog post for more information on the subject.

Best wishes,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
mc2000
Top achievements
Rank 1
answered on 21 Sep 2010, 12:41 PM
Hi: I am using the ScriptManager.RegisterStartupScript method and it's being called during the Page_Load event of my page being called. I tried moving the call to the PreInit method thinking the same thing and it didn't help. Thanks!
0
mc2000
Top achievements
Rank 1
answered on 21 Sep 2010, 12:49 PM
By the way, it DOES seem to find the control. When I put an alert in

oWnd = $find("<%=Window1.ClientID%>");
alert ("<%=Window1.ClientID%>");

I am getting a valid alert name. oWnd is just coming back null. (I also noticed there was an extra bracket in my original post which was a typo).
0
Georgi Tunev
Telerik team
answered on 21 Sep 2010, 03:08 PM
Hello mc2000,

You didn't specify what exactly you execute in RegisterStartupScript(), but just for testing - try executing it with a small timeout, e.g. window.setTimeout(function(){//your function}, 200) and see if the problem persists. If it doesn't, then you are calling the code too early. If the problems still exists, please open a support ticket and send me a sample project I can work on. I will check it and get back to you with a solution as soon as possible.

Regards,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
mc2000
Top achievements
Rank 1
answered on 21 Sep 2010, 05:57 PM
I'm calling the modal JavaScript function (from above) in my RegisterStartupScript block. By adding a timeout, the behavior does seem to work correctly always on my machine (I set it to 100). Is there a certain number this has to be set at to work correctly and / or is there another way to ensure this will work correctly for all users?

Thanks!
0
Georgi Tunev
Telerik team
answered on 24 Sep 2010, 09:39 AM
Hi mc2000,

If the timeout works, then (as I previously noted), the reason for the problem is that indeed your code is called too early - before the RadWindow is operational and fully rendered on the page. You can use the timeout approach (100-200 milliseconds should be enough) or if you have the time - you can isolate the problem in a sample project that shows your exact setup and send it to us in a support ticket. We will examine your case and provide you with the most appropriate solution that does not require additional timeout.



Kind regards,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
mc2000
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
mc2000
Top achievements
Rank 1
Share this question
or