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

Problem open RadWindow from RegisterStartupScript

2 Answers 330 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dany
Top achievements
Rank 1
Dany asked on 01 Oct 2010, 03:54 PM

Hi,  i try to update my Telerik DLL from "2009.1.402.20" to "2010.1.519.35" and having few issues, one of them is i try to open a RadWindow from my PageLoad event....

Everything is fine when i am open the RadWindow from a button but as soon as i try to open it automaticly from the page load event throught the RegisterStartupScript method i have an JS error " 'undefined' is null or not an object" see attachment for details

- Everything was fine with the previous version of the control
- Theres nothing in the code that could impact the functionnality because i use a brand new peoject with nothing else on it
- Doesn't matter if i am using the Window Script Manager or the RadScriptManager
- I suspect something in the control beacause in the JS error (see attachment) said error on line 3193... this it's weird because my html page result only have 148 lines....

To test this I have created a blank new WebProject and add the following code

 

Here's part of my CodeBehind Code :

 

 

 

 

 

protected void Page_Load(object sender, EventArgs e)

 

{

 

 

 

    RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "OpenDataSet", "ShowLanInsertForm();", true);

 

}

 

 

 

 

 

Here's part of my my HTML code :

 

 

 

 

<script type="text/javascript">

 

 

 

 

 

 

 

 

 

 

    function ShowLanInsertForm()

 

    {

        radopen(

 

 

"http://www.telerik.com", "RadWindow1");

 

    }

 

 

 

 

</script>

 

 

 



<

 

telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>

 

 

 


<

 

button onclick="ShowLanInsertForm(); return false;">open</button>

 

 

 



 

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">

 

 

 

 

<Windows>

 

 

 

 

<telerik:RadWindow

 

 

 

 

id="RadWindow1"

 

 

 

 

runat="server"

 

 

 

 

showcontentduringload="false"

 

 

 

 

width="400px"

 

 

 

 

height="400px"

 

 

 

 

title="Telerik RadWindow"

 

 

 

 

behaviors="Default">

 

 

 

 

</telerik:RadWindow>

 

 

 

 

</Windows>

 

 

 

 

</telerik:RadWindowManager>

 

 

 



2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Oct 2010, 05:23 AM
Hello,


Since you are using RadControls for ASP.NET AJAX, you should take into consideration that in MS AJAX environment, all Ajax controls (including Telerik) are loaded after the page itself is loaded (e.g. after window.onload) in Sys.Application.Load(). That means, you need to make sure that the controls are loaded on the page before trying to use them.

Another option is opening the window from server code as shown below:
protected void Button4_Click(object sender, EventArgs e) 
        RadWindow newWindow = new RadWindow(); 
        newWindow.NavigateUrl = "Default2.aspx"
        newWindow.VisibleOnPageLoad = true
        RadWindowManager1.Windows.Add(newWindow);  
}

Also check the following links:
http://www.telerik.com/community/forums/aspnet-ajax/window/want-to-pop-up-window-from-server-side.aspx
http://www.telerik.com/support/kb/aspnet-ajax/window/calling-radalert-from-codebehind.aspx


-Shinu.
0
Dany
Top achievements
Rank 1
answered on 04 Oct 2010, 02:48 PM
Nice it work perfectly that way, i just add thoses lines into my page load event and everything is fine !!!

Thanks again

        RadWindow newWindow = new RadWindow(); 
        newWindow.NavigateUrl = "Default2.aspx"
        newWindow.VisibleOnPageLoad = true
        RadWindowManager1.Windows.Add(newWindow);  
Tags
Window
Asked by
Dany
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dany
Top achievements
Rank 1
Share this question
or