Display HTML controls inside MS Treeview control.

This is the final product, looks very nice ;-).

Well, if you will add decode HTML to a TreeView node text the browser will render that HTML into visual controls inside the tree:

Microsoft.Web.UI.WebControls.TreeNode oNode1 = new Microsoft.Web.UI.WebControls.TreeNode();

oNode1.Text = Server.HtmlDecode("<INPUT style=\"Z-INDEX: 104\" type=\"text\">");

Microsoft.Web.UI.WebControls.TreeNode oNode = new Microsoft.Web.UI.WebControls.TreeNode();

oNode.Text = Server.HtmlDecode("<INPUT style=\"Z-INDEX: 104\" type=\"text\">");

oNode.Nodes.Add (oNode1);

this.TreeView2.Nodes.Add(oNode); 

As you see it’s pretty easy and might be useful. Naturally you can assign any attributes to those HTML controls, such as ID or events (including PostBacks).

3 Comments

  • Hi i am happy to find this article which i was searching for. Can u pls explain how can we get the values from the html control.

    thank u.

  • Using FindControl(). you just need to add ID and runat=server to insert HTML.

  • hello i added HTML radio button to the tree view nodes text with some other text.
    well i cretaed the interface but the problem is that i m not being able to access these controls even by findControl method.
    how can i access these radion button states?

Comments have been disabled for this content.