Custom NodeTemplate causes client side errors

2 posts, 0 answers
  1. Mike R
    Mike R avatar
    1 posts
    Member since:
    Dec 2009

    Posted 01 Dec 2009 Link to this post


    I am wondering if anyone can offer any suggestions to resolve an problem I am having.

    What I am trying to do: Programmatically create the equivalent of the NodeTemplate (as follows)

    <telerik:RadTreeView ...




    some html in here....




    This is an example of the server side code which programmatically adds the nodes to the tree and uses a custom NodeTemplate RadTreeNodeTemplate (see below)

    public class RadTreeNodeTemplate : ITemplate


    private string content;

    public RadTreeNodeTemplate(string text)


    content = text;


    #region ITemplate Members

    public void InstantiateIn(Control container)


    HtmlGenericControl nodeDiv = new HtmlGenericControl("div");

    nodeDiv.Visible = true;

    nodeDiv.InnerHtml = content;

    nodeDiv.EnableViewState = true;






    Tree building code:


    RadTreeNode node = new RadTreeNode();

    node.Expanded = true;

    node.NodeTemplate = new RadTreeNodeTemplate(question.LibraryQuestion.ShortDescription);

    node.Value = question.Id.ToString();



    The problem is with the programmatically generated nodes cause client-side errors when you mouse over them when they have html content.



    I figure the html rendered isn’t quite correct... What should I have my RadTreeNodeTemplate (custom ITemplate)

    Any help would be greatly appreciated.

    Cheers Michael

  2. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 02 Dec 2009 Link to this post


    I think you are right that HTML is not quite correct.

    I am using similar scenario, which renders perfectly:

     public void InstantiateIn(Control container) 
                    var node = (RadTreeNode)container; 
                    var lblNodeText = new Label(); 
                    lblNodeText.Text = node.Text; 
                    var inheritedText = node.Attributes["InheritedFrom"]; 
                    var br = new HtmlGenericControl("br"); 
                    var lblInheritedFrom = new Label(); 
                    lblInheritedFrom.Font.Italic = true
                    lblInheritedFrom.Text = inheritedText; 
                    if (!string.IsNullOrEmpty(inheritedText)) 
  3. DevCraft R3 2016 release webinar banner
Back to Top