Dynamically creating a RadTreeView Error

7 posts, 1 answers
  1. CBARS
    CBARS avatar
    55 posts
    Member since:
    Sep 2008

    Posted 29 Oct 2008 Link to this post

    Hi

    When I try to dynamically add a RadTreeView to a page, VS returns a JScript error, inside the Telerik.Web.UI.RadTreeView._preInitialize function.

    This is my page :

    <body> 
        <form id="form1" runat="server"
        <div> 
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
            </telerik:RadScriptManager> 
        </div> 
        </form> 
    </body> 

    my code-behind :

    namespace DynamicTreeViewTest 
        public partial class _Default : System.Web.UI.Page 
        { 
            protected void Page_Load(object sender, EventArgs e) 
            { 
                Telerik.Web.UI.RadTreeView testtree = new Telerik.Web.UI.RadTreeView(); 
                testtree.ID = "testtree"
                Telerik.Web.UI.RadTreeNode testnode = new Telerik.Web.UI.RadTreeNode("Node 1"); 
                testtree.Nodes.Add(testnode); 
                this.Controls.Add(testtree); 
            } 
        } 

    VS throws a null exception error, but the text is :

    Microsoft JScript runtime error: 'null' is null or not an object

    This is the code where the exception is thrown (line indicated) :

    Telerik.Web.UI.RadTreeView._preInitialize=function(_219,_21a){ 
    var _21b=$get(_219); 
    _21b.scrollTop=_21a; <-- Error
    if(Telerik.Web.UI.RadTreeView._isRtl(_21b)){ 
    Telerik.Web.UI.RadTreeView._initializeRtl(_21b); 
    }; 

    I've downloaded the new version of the controls (2008 Q2 1001), but they cause the same error.









  2. Answer
    Yana
    Admin
    Yana avatar
    4896 posts

    Posted 30 Oct 2008 Link to this post

    Hello,

    RadTreeView should be nested inside form element, so you have to add it like this:

    form1.Controls.Add(testtree);  

    Regards,
    Yana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Kailash
    Kailash avatar
    2 posts
    Member since:
    Jan 2009

    Posted 08 Jan 2009 Link to this post

    Well i have same kind of problem but in my case i am not adding Telerik Tree View control dynamically to page.
    I have an User Control and this UC contains a Telerik Tree View control that is nested inside a Panel. Now i put this UC in a webpartzone.
    Everything work fine but when i close this webpart i got this error at runtime.
    Please suggest.
    VS throws a null exception error, but the text is :

    Microsoft JScript runtime error: 'null' is null or not an object

    This is the code where the exception is thrown (line indicated) :

    Telerik.Web.UI.RadTreeView._preInitialize=function(_219,_21a){ 
    var _21b=$get(_219); 
    _21b.scrollTop=_21a; <-- Error
    if(Telerik.Web.UI.RadTreeView._isRtl(_21b)){ 
    Telerik.Web.UI.RadTreeView._initializeRtl(_21b); 
    }; 

  4. Christian
    Christian avatar
    37 posts
    Member since:
    Oct 2007

    Posted 24 Feb 2009 Link to this post

    Hi,
    I get the same Error.

    In my case, I have 5 different Ajaxsettings in the radajaxmanager.
    One of them is updating  the tree, for which the error occurs in the preinit step.
    But the Error only occurs if i set the tree to visible = false AND call an different async postback, which has nothing to do with the tree.
    the different asnyc postback updates an panel which hasn't any connection to the tree.
    In Fiddler I see at the async Postback, that a startupscript for the tree will be processed:

    scriptStartupBlock|ScriptContentNoTags|Telerik.Web.UI.RadTreeView._preInitialize("rtvLib","0");|1661

    any Idea?
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 24 Feb 2009 Link to this post

    Hi guys,

    Since it is hardly for us to reproduce the problem, can you please open support tickets and attach a sample working project there? We will debug it locally and give you more adequate answers.

    Thanks

    All the best,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Christian
    Christian avatar
    37 posts
    Member since:
    Oct 2007

    Posted 24 Feb 2009 Link to this post

    Ok,
    I found a solution for my problem. It was not enough to set the panel which is surounding the tree to visible=false. I had to set the visibility of the tree also to false. No it works.
  7. James
    James avatar
    35 posts
    Member since:
    Apr 2010

    Posted 06 May 2010 Link to this post

    My issue is similiar to Christian's but his suggestion isn't working for me. 

    In my scenario I have a div that is set to visible = false by default in the aspx code with the tree control inside the div. 

     

     

     

    <div id="divTree" runat="server" visible="false" enableviewstate="false">  
        <telerik:RadTreeView  ...  </telerik:RadTreeView> 
    </div> 

    On post-back, in the pageload, I would set visible = true on the div if certain conditions were met.  I would only get the error if I had the tree visible, went to another page, clicked the back button on the browser, and did a post-back to show the tree again.

    Other factors: 
      This div is in a User Control
      The page uses a master page
      The div is in a MuliPage control
      I'm using an ajax manager/proxy to perform the post back
      I'm using RadControls for ASP.NET AJAX Q1 2010 SP1

Back to Top