How to customize TreeNode object in ASP.NET

Each node in the TreeView control is represented by a TreeNode object. Every TreeNode has an associated piece of text, which is displayed in the tree. The TreeNode object provides navigation properties such as ChildNode (the collection of nodes it contains) and Parent (the containing node). The next table lists in details all the useful properties you can use:

 

Property

Description

TextThe text displayed in the tree for this node.
ToolTipThe tooltip text that appears when user hovers over the node text.
Value

You can use it to keep a value with additional data about the node. For example you can use it to store a unique ID, which you are planning to use when handling click events to identify the node or to look up more information. This value is not displayed.

NavigateUrl

You can use it to forward automatically the user to the corresponding URL when clicks this node. If you don’t set it you should write a code which will react to the TreeView.SelectedNodeChanged event to decide what action you want to perform.

Target

If the NavigateUrl property is set, this sets the target window or frame for the link. If Target isn’t set, the new page is opened in the current browser window. The TreeView also exposes a Target property, which you can set to apply a default target for all TreeNode instances.

ImageUrlThe image that’s displayed next to this node.
ImageToolTipThe tooltip text for the image displayed next to the node.