ID problem in radpane

2 posts, 1 answers
  1. york
    york avatar
    160 posts
    Member since:
    Jul 2012

    Posted 05 Mar 2011 Link to this post


    I tried to fill radpane in radsplitter with radtreeview. When I used
    var tree = $find("<%=RadTreeView1.ClientID %>"); = "100px";
    It crushed because tree is null. But when used
    var tree = document.getElementById("RadTreeView1"); = "100px";
    It worked fine. Why is that?
  2. Answer
    Marin Bratanov
    Marin Bratanov avatar
    3899 posts

    Posted 07 Mar 2011 Link to this post

    Hello York,

    I have already replied to this question in the other thread you posted. But for your convenience and to help others with similar problems I am posting it here, too:

    To get a null object you have probably attempted to get a reference to the object with the $find() method before the controls are initialized.

    On the other hand, you are actually trying to set a CSS style to an HTML element, so you need an object with a reference to an HTML element, not to a JavaScript object, as these objects do not have styles. This means that you must use the $get() method (a shortcut to the getElementById() method you are using) to get the reference.

    On the difference between these methods you can read in the MSDN articles on $find(), getElementById() and in this blog post.

    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top