Run Startup JS Code after Telerik JS Objects Exist

3 posts, 1 answers
  1. Eric
    Eric avatar
    5 posts
    Member since:
    Apr 2009

    Posted 01 Feb 2010 Link to this post

    // Find the RadControl client object, if null then exit the function  
    sb.Append(String.Format("var co = $find(\"{0}\");", c.ClientID));  
    sb.Append("if (co == null) return;");
     

    When I register this code with the Page.ClientScript.RegisterStartupScript method it attempts to execute before the Telerik Control Javascript objects are created resulting in "co" being assigned a null value.  How do I register startup Javascript code that executes AFTER the Telerik javascript objects are created.
  2. Answer
    T. Tsonev
    Admin
    T. Tsonev avatar
    2770 posts

    Posted 03 Feb 2010 Link to this post

    Hi Eric,

    The client-side objects of the controls are available after the MS AJAX framework has been initialized. You need to either place your code in a function named pageLoad or use the load event of Sys.Application:

    Copy Code
    function pageLoad()
    {
    }
     
    // OR
     
    // Attach a handler to the load event.
    Sys.Application.add_load(applicationLoad);
     
    function applicationLoad()
    {
    }

    I hope this helps.

    All the best,
    Tsvetomir Tsonev
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eric
    Eric avatar
    5 posts
    Member since:
    Apr 2009

    Posted 03 Feb 2010 Link to this post

    Perfect!  Thank you!
Back to Top