Problem open RadWindow from RegisterStartupScript

3 posts, 0 answers
  1. Dany
    Dany avatar
    12 posts
    Member since:
    Apr 2009

    Posted 01 Oct 2010 Link to this post

    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. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Oct 2010 Link to this post

    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.
  3. Dany
    Dany avatar
    12 posts
    Member since:
    Apr 2009

    Posted 04 Oct 2010 Link to this post

    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);  
Back to Top