System.Web
2.0.0.0
System.Web.UI.WebControls.HierarchicalDataBoundControl
System.Web.UI.ICallbackEventHandler
System.Web.UI.IPostBackDataHandler
System.Web.UI.IPostBackEventHandler
System.ComponentModel.Designer("System.Web.UI.Design.WebControls.TreeViewDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")
System.ComponentModel.DefaultEvent("SelectedNodeChanged")
System.Web.UI.ControlValueProperty("SelectedValue")
System.Web.UI.SupportsEventValidation
In this topic:
-
Introduction
-
Nodes
-
Static Data
-
Binding to Data
-
Dynamic Node Population
-
Customizing the User Interface
-
Events
-
Scrolling
-
Accessibility
-
Declarative Syntax
Introduction
The control is used to display hierarchical data, such as a table of contents or file directory, in a tree structure and supports the following features:
-
Data binding that allows the nodes of the control to be bound to XML, tabular, or relational data.
-
Site navigation through integration with the control.
-
Node text that can be displayed as either plain text or hyperlinks.
-
Programmatic access to the object model to create trees, populate nodes, set properties, and so on dynamically.
-
Client-side node population (on supported browsers).
-
The ability to display a check box next to each node.
-
Customizable appearance through themes, user-defined images, and styles.
The control is designed to be used inside an control only when is set to true. controls are used to update selected regions of a page instead of updating the whole page with a postback. For more information, see UpdatePanel Control Overview and Partial-Page Rendering Overview.
Nodes
The control is made up of nodes. Each entry in the tree is called a node and is represented by a object. Node types are defined as follows:
-
A node that contains other nodes is called a parent node.
-
The node that is contained by another node is called a child node.
-
A node that has no children is called a leaf node.
-
The node that is not contained by any other node but is the ancestor to all the other nodes is the root node.
A node can be both a parent and a child, but root, parent, and leaf nodes are mutually exclusive. Several visual and behavioral properties of nodes are determined by whether a node is a root, child, or leaf node.
Although a typical tree structure has only one root node, the control allows you to add multiple root nodes to your tree structure. This is useful when you want to display item listings without displaying a single root node, as in a list of product categories.
Each node has a property and a property. The value of the property is displayed in the , while the property is used to store any additional data about the node, such as data that is passed to the postback event that is associated with the node.
A node can be in one of two modes: selection mode and navigation mode. By default, a node is in selection mode. To put a node into navigation mode, set the property for the node to a value other than an empty string (""). To put a node into selection mode, set the property for the node to an empty string ("").
Some Internet browsers have a limitation that can affect the performance of the control. For example, Microsoft Internet Explorer 6.0 has a URL character limit of 2067 characters that it posts. If the number of characters in a URL of a node is larger than that number, expanding that node will fail and no exception is thrown.
Static Data
The simplest data model of the control is static data. To display static data using declarative syntax, first nest opening and closing <Nodes> tags between the opening and closing tags of the control. Next, create the tree structure by nesting <asp:TreeNode> elements between the opening and closing <Nodes> tags. Each <asp:TreeNode> element represents a node in the tree and maps to a object. You can set the properties of each node by setting the attributes of its <asp:TreeNode> element. To create child nodes, nest additional <asp:TreeNode> elements between the opening and closing <asp:TreeNode> tags of the parent node.
Binding to Data
The control can also be bound to data. You can use either of two methods to bind the control to the appropriate data source type:
-
The control can use any data source control that implements the interface, such as an control or a control. To bind to a data source control, set the property of the control to the value of the data source control. The control automatically binds to the specified data source control. This is the preferred method to bind to data.
-
The control can also be bound to an object or a object with relations. To bind to one of these data sources, set the property of the control to the data source, and then call the method.
When binding to a data source where each data item contains multiple properties (such as an XML element with several attributes), a node displays the value that is returned by the ToString method of the data item, by default. In the case of an XML element, the node displays the element name, which shows the underlying structure of the tree but is not very useful otherwise. You can bind a node to a specific data item property by specifying tree node bindings using the collection. The collection contains TreeNodeBinding objects that define the relationship between a data item and the node that it is binding to. You can specify the criteria for binding and the data item property to display in the node. For more information on tree node bindings, see .
A malicious user can create a callback request and get data for the nodes of the control that the page developer is not displaying. Therefore, security of the data must be implemented by the data source. Do not use the property to hide data.
Dynamic Node Population
Sometimes, it is not practical to statically define the tree structure because the data source returns too much data or because the data to display depends on information that you get at run time. Because of this, the control supports dynamic node population. When the property for a node is set to true, that node gets populated at run time when the node is expanded. To populate a node dynamically, you must define an event-handling method that contains the logic to populate a node for the event.
Browsers that support callback scripts can also take advantage of client-side node population. (This includes Internet Explorer 5.5 and later and some other browsers.) Client-side node population enables the control to populate a node using client script when users expand the node, without requiring a round trip to the server. For more information on client-side node population, see .
Customizing the User Interface
There are many ways to customize the appearance of the control. First, you can specify a different style (such as font size and color) for each of the node types.
If you use cascading style sheets (CSS) to customize the appearance of the control, use either inline styles or a separate CSS file, but not both. Using both inline styles and a separate CSS file could cause unexpected results. For more information on using style sheets with controls, see ASP.NET Web Server Controls and CSS Styles.
The following table lists the available node styles.
-
Node style property
Description
-
The style settings for a node when the mouse pointer is positioned over it.
-
The style settings for the leaf nodes.
-
The default style settings for a node.
-
The style settings for the parent nodes.
-
The style settings for the root node.
-
The style settings for a selected node.
You can also control the style of nodes at specific depths within the tree by using the collection. The first style in the collection corresponds to the style of the nodes at the first level in the tree. The second style in the collection corresponds to the style of the nodes at the second level in the tree, and so on. This is most often used to generate table of contents–style navigation menus where nodes at a certain depth should have the same appearance, regardless of whether they have child nodes.
If a style is defined for a certain depth level using the collection, that style overrides any root, parent, or leaf node style settings for the nodes at that depth.
Another way to alter the appearance of the control is to customize the images that are displayed in the control. You can specify your own custom set of images for the different parts of the control by setting the properties shown in the following table.
-
Image property
Description
-
The URL to an image displayed for the collapsible node indicator. This image is usually a minus sign (-).
-
The URL to an image displayed for the expandable node indicator. This image is usually a plus sign (+).
-
The URL to the folder containing the line images used to connect parent nodes to child nodes. The property must also be set to true for this property to have an effect.
-
The URL to an image displayed for the non-expandable node indicator.
You do not need to customize every image property. If an image property is not explicitly set, the built-in default image is used.
The control also allows you to display a check box next to a node. When the property is set to a value other than TreeNodeTypes.None, check boxes are displayed next to the specified node types.
The property can be set to a bitwise combination of the enumeration member values.
Each time the page is posted to the server, the collection is automatically populated with the selected nodes. When check boxes are displayed, you can use the event to run a custom routine whenever the state of a check box changes between posts to the server.
Events
The control provides several events that you can program against. This allows you to run a custom routine whenever an event occurs. The following table lists the events that are supported by the control.
-
Event
Description
-
Occurs when the check boxes of the control change state between posts to the server.
-
Occurs when a node is selected in the control.
-
Occurs when a node is expanded in the control.
-
Occurs when a node is collapsed in the control.
-
Occurs when a node with its property set to true is expanded in the control.
-
Occurs when a data item is bound to a node in the control.
Scrolling
The control does not have built-in scrolling. To add scrolling, place the control in a control and add scrollbars to the control. For more information, see Panel Web Server Control Overview.
Accessibility
The markup rendered by default for this control might not conform to accessibility standards. For details about accessibility support for this control, see ASP.NET Controls and Accessibility.
Declarative Syntax
<asp:TreeView
AccessKey="string"
AutoGenerateDataBindings="True|False"
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
Inset|Outset"
BorderWidth="size"
CollapseImageToolTip="string"
CollapseImageUrl="uri"
CssClass="string"
DataSource="string"
DataSourceID="string"
EnableClientScript="True|False"
Enabled="True|False"
EnableTheming="True|False"
EnableViewState="True|False"
ExpandDepth="string|FullyExpand|0|1|2|3|4|5|6|7|8|9|10|11|12|13|
14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30"
ExpandImageToolTip="string"
ExpandImageUrl="uri"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
ID="string"
ImageSet="Custom|XPFileExplorer|Msdn|WindowsHelp|Simple|Simple2|
BulletedList|BulletedList2|BulletedList3|BulletedList4|
Arrows|News|Contacts|Inbox|Events|Faq"
LineImagesFolder="string"
MaxDataBindDepth="integer"
NodeIndent="integer"
NodeWrap="True|False"
NoExpandImageUrl="uri"
OnDataBinding="DataBinding event handler"
OnDataBound="DataBound event handler"
OnDisposed="Disposed event handler"
OnInit="Init event handler"
OnLoad="Load event handler"
OnPreRender="PreRender event handler"
OnSelectedNodeChanged="SelectedNodeChanged event handler"
OnTreeNodeCheckChanged="TreeNodeCheckChanged event handler"
OnTreeNodeCollapsed="TreeNodeCollapsed event handler"
OnTreeNodeDataBound="TreeNodeDataBound event handler"
OnTreeNodeExpanded="TreeNodeExpanded event handler"
OnTreeNodePopulate="TreeNodePopulate event handler"
OnUnload="Unload event handler"
PathSeparator="string"
PopulateNodesFromClient="True|False"
runat="server"
ShowCheckBoxes="None|Root|Parent|Leaf|All"
ShowExpandCollapse="True|False"
ShowLines="True|False"
SkinID="string"
SkipLinkText="string"
Style="string"
TabIndex="integer"
Target="string"
ToolTip="string"
Visible="True|False"
Width="size"
>
<DataBindings>
<asp:TreeNodeBinding
DataMember="string"
Depth="integer"
FormatString="string"
ImageToolTip="string"
ImageToolTipField="string"
ImageUrl="uri"
ImageUrlField="string"
NavigateUrl="uri"
NavigateUrlField="string"
PopulateOnDemand="True|False"
SelectAction="Select|Expand|SelectExpand|None"
ShowCheckBox="string"
Target="string"
TargetField="string"
Text="string"
TextField="string"
ToolTip="string"
ToolTipField="string"
Value="string"
ValueField="string"
/>
</DataBindings>
<HoverNodeStyle />
<LeafNodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
<LevelStyles>
<asp:TreeNodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|
Double|Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|
X-Small|Small|Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
</LevelStyles>
<Nodes>
<asp:TreeNode
Checked="True|False"
Expanded="string"
ImageToolTip="string"
ImageUrl="uri"
NavigateUrl="uri"
PopulateOnDemand="True|False"
SelectAction="Select|Expand|SelectExpand|None"
Selected="True|False"
ShowCheckBox="string"
Target="string"
Text="string"
ToolTip="string"
Value="string"
>
</asp:TreeNode>
</Nodes>
<NodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
<ParentNodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
<RootNodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
<SelectedNodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
</asp:TreeView>
Displays hierarchical data, such as a table of contents, in a tree structure.
Constructor
Use the constructor to create and initialize a new instance of the class. To add a control to a page dynamically, create a new object, set its properties, and then add it to the collection of a container control, such as the control.
Initializes a new instance of the class.
2.0.0.0
Method
System.Void
The method is used primarily by control developers.
Adds HTML attributes and styles that need to be rendered to the specified control.
An that represents the output stream to render HTML content on the client.
2.0.0.0
Property
System.ComponentModel.DefaultValue(true)
System.Boolean
To be added.
Tree node bindings define the relationship between a data item and the node it is binding to. When binding to a data source where each data item contains multiple properties (such as an XML element with several attributes), the control needs to know which data item property to bind to which property. If the property is set to true, the control automatically generates default tree node bindings that set the property of the object that is associated with the binding to the value that is returned by the ToString method of the data item.
The automatically generated tree node bindings are not added to the collection.
In the case of an XML element, the value that is returned by the ToString method is the element name, which shows the underlying structure of the XML file, but is not very useful otherwise. To create a more useful tree, you must define your own tree node bindings by populating the collection.
If you define a collection, the control uses those values instead of automatically generated tree node bindings.
The value of this property is stored in view state.
Gets or sets a value indicating whether the control automatically generates tree node bindings.
2.0.0.0
Property
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
System.ComponentModel.Browsable(false)
System.Web.UI.WebControls.TreeNodeCollection
To be added.
When check boxes are displayed in the control (by setting the property to a value other than TreeNodeType.None), use the property to determine which nodes display a selected check box. This collection is commonly used to iterate through all the nodes that have a selected check box in the tree.
The event is raised when the check boxes of the control change state between posts to the server. This allows you to provide an event-handling method that performs a custom routine, such as updating a database or the displayed content, whenever this event occurs.
The collection is populated using a depth-first traversal of the tree structure: each parent node is processed down to its child nodes before the next parent node is populated.
Gets a collection of objects that represent the nodes in the control that display a selected check box.
2.0.0.0
Method
System.Void
The method provides a convenient way to close every node in the tree.
Closes every node in the tree.
2.0.0.0
Property
System.ComponentModel.Localizable(true)
System.String
To be added.
Use the property to specify a ToolTip for the collapsible image. The text that you specify provides Assistive Technology devices with a description of the image that can be used to make the control more accessible.
The value of this property is stored in view state.
The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and ASP.NET Globalization and Localization.
Gets or sets the ToolTip for the image that is displayed for the collapsible node indicator.
2.0.0.0
Property
System.ComponentModel.Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
System.Web.UI.UrlProperty
System.ComponentModel.DefaultValue("")
System.String
To be added.
Use the property to specify a custom image for the collapsible node indicator. This image is displayed next to a collapsible node and is usually a minus sign (-).
When the property is set to true, the control displays a plus sign (+) or a minus sign(-) or a placeholder image next to a node to indicate whether the node is expandable, collapsible, or non-expandable, respectively. You can specify custom images by first setting the property to TreeViewImageSet.Custom, and then setting the , , and properties to the URLs for the custom images. If no images are specified, the default images are used. To hide the expansion node indicators, set the property to false.
To ensure that nodes align correctly in the control when using custom images, make sure that all the images that are specified by the , , and properties have the same dimensions.
When using a custom image for the collapsible node indicator, you should also consider setting the property to specify a ToolTip for the image.
The value of this property is stored in view state.
Gets or sets the URL to a custom image for the collapsible node indicator.
2.0.0.0
Method
System.Web.UI.ControlCollection
The control does not support embedding of child controls. This method has been overridden to prevent the addition of child controls and always returns an object.
Creates a collection to store child controls.
Always returns an .
2.0.0.0
Method
2.0.0.0
System.Web.UI.WebControls.TreeNode
The method is a helper method that returns a new instance of the class.
The method is used primarily by control developers. Control developers that want to extend the class by extending the class should override this method to return an object that derives from the . A common reason to extend the class is to override the and methods.
Returns a new instance of the class. The is a helper method.
A new instance of the .
Method
System.Void
Data bound controls should override the method instead of the method.
Calls the method of the base class.
2.0.0.0
Property
System.ComponentModel.MergableProperty(false)
System.ComponentModel.DefaultValue(null)
System.ComponentModel.Editor("System.Web.UI.Design.WebControls.TreeViewBindingsEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
System.Web.UI.WebControls.TreeNodeBindingCollection
To be added.
The collection contains objects that define the relationship between a data item and the node that it is binding to. When binding to a data source where each data item contains multiple properties (such as an XML element with several attributes), a node displays the value that is returned by the ToString method of the data item, by default. In the case of an XML element, the node displays the element name, which shows the underlying structure of the tree, but is not very useful otherwise. You can bind a node to a specific data item property by specifying tree node bindings.
When defining the relationship between a data item and a node, you must specify both the criteria for binding and the values to bind to the properties of object. The criteria indicate when a data item should be bound to a node. The criteria can be specified with a node depth, a data member, or both. A node depth specifies the node level that gets bound. For example, if you specify a node depth of 0, all nodes in the tree structure at level 0 are bound using the tree node binding. A data member specifies the type of the data item in the underlying data source, but can represent different information depending on the data source. For example, the data member for an XML element specifies the name of the element.
If multiple objects are defined that conflict with each other, the control applies the tree node bindings in the following order of precedence:
-
The object that defines both a depth and a data member.
-
The object that defines only the depth.
-
The object that defines only the data member.
-
The object that defines neither the depth nor the data member.
If multiple bindings are specified that meet the same precedence criteria, the first binding in the collection is applied.
Once the binding criteria is established, you can then bind a property of a object that can be bound to a value. You can either bind to an attribute or field of a data item or display a static value. For more information on binding the properties of a object to a value, see .
Although the collection can be programmatically populated, it is usually set declaratively. To specify the tree node bindings, first nest opening and closing <DataBindings> tags between the opening and closing tags of the control. Next, place <asp:TreeNodeBinding> elements between the opening and closing <DataBindings> tags for each tree node binding you want to specify.
When data bindings are created by setting the property of the control to true, the bindings that are created have the property set to true. Data bindings that are created declaratively have the property set to false. Using the declarative syntax allows you to control the behavior of individual data bindings.
Gets a collection of objects that define the relationship between a data item and the node that it is binding to.
2.0.0.0
Property
System.ComponentModel.DefaultValue(true)
System.Web.UI.Themeable(false)
System.Boolean
To be added.
Use the property to specify whether the control renders client-side script on compatible browsers to handle expanding and collapsing events. When this property is set to true, compatible browsers execute the code to expand and collapse nodes on the client. The tree node data must be known in advance for the client-side script to work. Using client script prevents a post back to the server each time a node is expanded or collapsed.
When the tree node data is not known in advance, nodes can be populated from the client, if the PopulateNodesFromClient property is also set to true. In this scenario, you must also provide an event-handling method for the event to populate the nodes. For more information on client-side node population, see .
If the property is set to false, the control posts back to the server each time a node is expanded or collapsed.
The value of this property is stored in view state.
This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview.
Gets or sets a value indicating whether the control renders client-side script to handle expanding and collapsing events.
2.0.0.0
Method
System.Void
The method provides a convenient way to open every node in the tree.
Opens every node in the tree.
2.0.0.0
Property
System.ComponentModel.TypeConverter("System.Web.UI.WebControls.TreeView+TreeViewExpandDepthConverter, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
System.ComponentModel.DefaultValue(-1)
System.Int32
To be added.
Use the property to control the rendering of the control the first time that it is displayed. On subsequent postbacks, the nodes retain their current expanded state.
Gets or sets the number of levels that are expanded when a control is displayed for the first time.
2.0.0.0
Property
System.ComponentModel.Localizable(true)
System.String
To be added.
Use the property to specify a ToolTip for the image. The text that you specify provides Assistive Technology devices with a description of the image that can be used to make the control more accessible.
The value of this property is stored in view state.
The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and ASP.NET Globalization and Localization.
Gets or sets the ToolTip for the image that is displayed for the expandable node indicator.
2.0.0.0
Property
System.ComponentModel.Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
System.Web.UI.UrlProperty
System.ComponentModel.DefaultValue("")
System.String
To be added.
Use the property to specify a custom image for the expandable node indicator. This image is displayed next to an expandable node and is usually a plus sign (+).
When the property is set to true, the control displays a plus sign (+) or minus sign (-) or a placeholder image next to a node to indicate whether the node is expandable, collapsible, or non-expandable, respectively. You can specify custom images by first setting the property to TreeViewImageSet.Custom, and then setting the , , and properties to the URLs for the custom images. If no images are specified, the default images are used. To hide the expansion node indicators, set the property to false.
To ensure that nodes align correctly in the control when using custom images, make sure that all the images that are specified by the , , and properties have the same dimensions.
To display a custom image correctly, you may need to set to false.
When using a custom image for the expandable node indicator, you should also consider setting the property to specify a ToolTip for the image.
The value of this property is stored in view state.
Gets or sets the URL to a custom image for the expandable node indicator.
2.0.0.0
Method
System.Web.UI.WebControls.TreeNode
Use the method to get a node from the control at the specified value path. The value path contains a delimiter-separated list of node values that form a path from the root node to the current node. Each node stores its value path in the property. The property specifies the delimiter character that is used to separate the node values.
Retrieves the object in the control at the specified value path.
The at the specified value path.
The value path of a node.
2.0.0.0
Method
System.String
The control implements the interface and uses the to retrieve data and the method to return the retrieved data to the control.
Returns the result of a callback event that targets a control.
The results of the callback.
2.0.0.0
Property
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
System.ComponentModel.DefaultValue(null)
System.ComponentModel.NotifyParentProperty(true)
System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
System.Web.UI.WebControls.Style
To be added.
Use the property to control the appearance of a node when the mouse pointer is positioned over it. This property is read-only; however, you can set the properties of the object that it returns. The properties can be set declaratively in the form , where is a property of the object (for example, HoverNodeStyle-ForeColor). The properties can also be set programmatically in the form (for example, HoverNodeStyle.ForeColor). This feature is supported only on script-capable clients.
To use the property, you must include a <head> element with a runat="server" attribute.
Common settings usually include a custom background color, foreground color, font properties, and node spacing. Style properties are applied in the following order:
-
.
-
, , or , depending on the node type. If the collection is defined, it is applied at this time, overriding the other node style properties.
-
.
-
.
The style settings for the property override any corresponding node style settings that are in the , , , , or property.
The property is not rendered for a node with its property set to TreeNodeSelectAction.None.
Unlike the and the properties, which are objects, the property is a object.
Gets a reference to the object that allows you to set the appearance of a node when the mouse pointer is positioned over it.
2.0.0.0
Property
System.ComponentModel.DefaultValue(System.Web.UI.WebControls.TreeViewImageSet.Custom)
System.Web.UI.WebControls.TreeViewImageSet
To be added.
Use the property to specify the group of images to use for the control. You can either select a predefined set of images to give the control a standard look or define your own custom set.
The property does not affect any style settings for a node. Set the appropriate style property, such as the property, if you want to add custom colors and spacing.
The following table lists the valid values for The property.
-
Image set
Description
-
TreeViewImageSet.Arrows
A predefined image set that uses arrow images.
-
TreeViewImageSet.BulletedList
A predefined image set that uses diamond-shaped bullet images.
-
TreeViewImageSet.BulletedList2
A predefined image set that uses square-shaped bullet images.
-
TreeViewImageSet.BulletedList3
A predefined set of sectioned, diamond shaped bullet images.
-
TreeViewImageSet.BulletedList4
A predefined set of alternate sectioned, diamond shaped bullet images in sizes that vary by level.
-
TreeViewImageSet.Contacts
A predefined image set that uses MSN Messenger images.
-
TreeViewImageSet.Custom
A user-defined image set.
-
TreeViewImageSet.Events
A predefined image set that uses event log-styled images.
-
TreeViewImageSet.Faq
A predefined image set that uses FAQ-styled images.
-
TreeViewImageSet.Inbox
A predefined image set that uses e-mail-styled images.
-
TreeViewImageSet.News
A predefined image set that uses newsgroup-styled images.
-
TreeViewImageSet.Simple
A predefined image set that uses simple shape outlines.
-
TreeViewImageSet.Simple2
A predefined image set that uses simple filled shapes.
-
TreeViewImageSet.Msdn
A predefined image set that uses MSDN images.
-
TreeViewImageSet.WindowsHelp
A predefined image set that uses Microsoft Windows Help images.
-
TreeViewImageSet.XPFileExplorer
A predefined image set that uses Windows Explorer images available in Microsoft Windows XP.
When defining a custom set of images, you should specify an image for each of the properties in the following table. Otherwise, the default image for that property is used.
-
Property
Description
-
The URL to a custom image for the collapsible node indicator.
-
The URL to a custom image for the expandable node indicator.
-
The URL to a folder that contains custom images for the lines that connect nodes.
-
The URL to a custom image for the non-expandable node indicator.
The value of this property is stored in view state.
Gets or sets the group of images to use for the control.
2.0.0.0
Property
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
System.ComponentModel.DefaultValue(null)
System.ComponentModel.NotifyParentProperty(true)
System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
System.Web.UI.WebControls.TreeNodeStyle
To be added.
Use the property to control the appearance of the leaf nodes in the control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively in the form , where is a property of the object (for example, LeafNodeStyle-ForeColor). The properties can also be set programmatically in the form (for example, LeafNodeStyle.ForeColor). Common settings usually include a custom background color, foreground color, font properties, and node spacing. Style properties are applied in the following order of precedence:
-
.
-
, , or , depending on the node type. If the collection is defined, it is applied at this time, overriding the other node style properties.
-
.
-
.
If you need to generate table of contents–style navigation menus where nodes at a certain level should have the same appearance, regardless of whether they have child nodes, you might consider using the property instead of setting the individual style properties.
Gets a reference to the object that allows you to set the appearance of leaf nodes.
2.0.0.0
Property
System.ComponentModel.Editor("System.Web.UI.Design.WebControls.TreeNodeStyleCollectionEditor,System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
System.ComponentModel.DefaultValue(null)
System.Web.UI.WebControls.TreeNodeStyleCollection
To be added.
Use the collection as an alternative to the individual style properties (such as the property) to control the style of nodes at the individual levels of the tree. The first style in the collection corresponds to the style of nodes in the first level of the tree. The second style in the collection corresponds to the style of nodes in the second level of the tree, and so on. This property is most often used to generate table of contents–style navigation menus where nodes at a certain level should have the same appearance, regardless of whether they have child nodes.
Style properties are applied in the following order:
-
.
-
, , or , depending on the node type. If the collection is defined, it is applied at this time, overriding the other node style properties.
-
.
-
Gets a collection of objects that represent the node styles at the individual levels of the tree.
2.0.0.0
Property
System.ComponentModel.DefaultValue("")
System.String
To be added.
The control can display lines that connect child nodes to parent nodes when the property is set to true. When lines are displayed, use the property to specify a Web-accessible folder that contains the set of pre-rendered images to use for the lines. The following table describes the images that are used by the control.
-
Image
Description
-
Dash.gif
A line image displayed next to the root node when there is only one root node in the tree structure and the root node is a leaf.
-
Dashminus.gif
A minus sign (-) image displayed next to the root node when there is only one root node in the tree structure to indicate that the root node is expanded.
-
Dashplus.gif
A plus sign (+) image displayed next to the root node when there is only one root node in the tree structure to indicate that the root node is collapsed.
-
I.gif
A line image displayed to connect adjacent nodes.
-
L.gif
A line image displayed next to the last node in a branch when the node is a leaf.
-
Lminus.gif
A line image displayed next to the last node in a branch to indicate that the node is expanded.
-
Lplus.gif
A line image displayed next to the last node in a branch to indicate that the node is collapsed.
-
Minus.gif
A minus sign (-) image displayed next to the first root node in a tree structure that contains multiple root nodes to indicate that the node is expanded. This image does not contain an extra line and is displayed only after the root node has been collapsed once. When the page is first loaded, the Rminus.gif image is displayed.
-
Noexpand.gif
A blank spacer image displayed next to a leaf node. This image allows text to line up vertically.
-
Plus.gif
A plus sign (+) image displayed next to the first root node in a tree structure that contains multiple root nodes to indicate that the node is collapsed. This image does not contain an extra line and is displayed only after the root node has been expanded once. When the page is first loaded, the Rplus.gif image is displayed.
-
R.gif
A line image displayed next to the first root node in a tree structure that contains multiple root nodes to indicate that the node is a leaf node.
-
Rminus.gif
A minus sign (-) image displayed next to the first root node in a tree structure that contains multiple root nodes to indicate that the node is expanded. This image contains an extra line and is displayed only when the page is first loaded. After the root node has been collapsed once, The Minus.gif image is displayed.
-
Rplus.gif
A plus sign (+) image displayed next to the first root node in a tree structure that contains multiple root nodes to indicate that the node is collapsed. This image contains an extra line and is displayed only when the page is first loaded. After the root node has been expanded once, the Plus.gif image is displayed.
-
T.gif
A line image displayed next to a node in the middle of the tree structure (at a t-intersection) to indicate that the node is a leaf.
-
Tminus.gif
A minus sign (-) image displayed next to a node in the middle of the tree structure (at a t-intersection) to indicate that the node is expanded.
-
Tplus.gif
A plus sign (+) image displayed next to a node in the middle of the tree structure (at a t-intersection) to indicate that the node is collapsed.
If the property is not set, the control will use the built-in, default images (20 x 20 pixels).
Some visual designers, such as Microsoft Visual Studio, provide tools to generate the line images.
The run time does not flip custom images for right-to-left displays. To support both left-to-right and right-to-left Web pages, you must create image sets for both directions.
The value of this property is stored in view state.
Gets or sets the path to a folder that contains the line images that are used to connect child nodes to parent nodes.
2.0.0.0
Method
System.Boolean
The ASP.NET page framework tracks all the server controls that return true from the method call, and then invokes the method on those controls.
Processes postback data for the control.
true, if the control's state changes as a result of the postback event; otherwise, false.
The key identifier for the control.
The collection of all incoming name values.
2.0.0.0
Method
System.Void
To be added.
To be added.
Loads the previously saved view state of the control.
2.0.0.0
Property
System.ComponentModel.DefaultValue(-1)
System.Int32
To be added.
When binding the control to a data source, use the property to limit the number of tree levels to bind to the control. For example, setting this property to 2 binds only the root node and any nodes that are immediately under the root node to the control. All remaining nodes in the data source are ignored.
A malicious user can create a callback request and get data for the nodes of the control that the page developer is not displaying. Therefore, security of the data must be implemented by the data source. Do not use the property to hide data.
The value of this property is stored in view state.
Gets or sets the maximum number of tree levels to bind to the control.
2.0.0.0
Property
System.ComponentModel.DefaultValue(20)
System.Int32
To be added.
Use the property to control the amount of spacing between the left edge of a child node and the left edge of its parent node.
The property affects every child node in the control. It is not possible to control the indentation amount of each node individually.
The value of this property is stored in view state.
Gets or sets the indentation amount (in pixels) for the child nodes of the control.
2.0.0.0
Property
System.ComponentModel.MergableProperty(false)
System.ComponentModel.DefaultValue(null)
System.ComponentModel.Editor("System.Web.UI.Design.WebControls.TreeNodeCollectionEditor,System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
System.Web.UI.WebControls.TreeNodeCollection
To be added.
Use the property to get a object that contains all the root nodes in the tree. This collection is commonly used to quickly iterate through all the root nodes, or to access a specific root node in the tree.
A typical tree structure has only one root node; however, you can add multiple root nodes to the control.
The property can also be used to manage the root nodes in the tree programmatically. You can add, insert, remove, and retrieve objects from the collection. Any updates to the collection are automatically reflected in the control after the next round trip to the server.
To access the child nodes of a root node, use the property of the node. Use the property of each subsequent parent-level node to navigate down the node levels.
Gets a collection of objects that represents the root nodes in the control.
2.0.0.0
Property
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
System.ComponentModel.DefaultValue(null)
System.ComponentModel.NotifyParentProperty(true)
System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
System.Web.UI.WebControls.TreeNodeStyle
To be added.
Use the property to control the default appearance of a node in the control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively in the form , where is a property of the object (for example, NodeStyle-ForeColor). The properties can also be set programmatically in the form (for example, NodeStyle.ForeColor). Common settings usually include a custom background color, foreground color, font properties, and node spacing. Style properties are applied in the following order of precedence:
-
.
-
, , or , depending on the node type. If the collection is defined, it is applied at this time, overriding the other node style properties.
-
.
-
.
The corresponding node style settings in the , , or properties override the style settings of the property.
If you need to generate table of contents-style navigation menus where nodes at a certain level should have the same appearance, regardless of whether they have child nodes, you might consider using the property instead of setting the individual style properties.
Gets a reference to the object that allows you to set the default appearance of the nodes in the control.
2.0.0.0
Property
System.ComponentModel.DefaultValue(false)
System.Boolean
To be added.
Use the property to specify whether the text that is displayed in each node wraps when it runs out of space.
The value of this property is stored in view state.
Gets or sets a value indicating whether text wraps in a node when the node runs out of space.
2.0.0.0
Property
System.ComponentModel.Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
System.ComponentModel.DefaultValue("")
System.Web.UI.UrlProperty
System.String
To be added.
Use the property to specify a custom image for the non-expandable node indicator. The non-expandable node indicator image (or spacer) is displayed next to leaf nodes (in place of the expandable and collapsible node indicators) to align the leaf nodes with parent or root nodes.
When the property is set to true, the control displays a plus sign (+) or minus sign (-) or a placeholder image next to a node to indicate whether the node is expandable, collapsible, or non-expandable, respectively. You can specify custom images by first setting the property to TreeViewImageSet.Custom, and then setting the , , and properties to the URLs of the custom images. If no images are specified, the default images are used. To hide the expansion node indicators, set the property to false.
To ensure that nodes align correctly in the control when using custom images, make sure that all the images that are specified by the , , and properties have the same dimensions.
The value of this property is stored in view state.
Gets or sets the URL to a custom image for the non-expandable node indicator.
2.0.0.0
Method
2.0.0.0
System.Void
The method is called by the control to raise the event. It is generally used by control developers when extending the class.
Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Raises the event.
An that contains the event data.
Method
2.0.0.0
System.Void
The method is overridden to register for postback. If client script is enabled, it also renders the necessary script and hidden fields.
Raising an event invokes the event handler through a delegate. For more information, see Consuming Events.
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Raises the event.
An that contains event data.
Method
System.Void
The event is raised when a node is selected in the control. This allows you to provide an event-handling method that performs a custom routine, such as updating the displayed content, whenever this event occurs.
You can optionally set the property of a node to specify which event is raised when that node is selected.
The is not rendered for a node with its property set to TreeNodeSelectAction.None.
Raising an event invokes the event handler through a delegate. For more information, see Consuming Events.
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Raises the event of the control.
An that contains event data.
2.0.0.0
Method
System.Void
The event is raised when a check box in the control changes state between posts to the server. This allows you to provide an event-handling method that performs a custom routine, such as updating a database or the displayed content, whenever this event occurs.
Raising an event invokes the event handler through a delegate. For more information, see Consuming Events.
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Raises the event of the control.
A that contains event data.
2.0.0.0
Method
System.Void
The event is raised when a node is collapsed in the control. This allows you to provide an event-handling method that performs a custom routine whenever this event occurs.
Raising an event invokes the event handler through a delegate. For more information, see Consuming Events.
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Raises the event of the control.
A that contains event data.
2.0.0.0
Method
System.Void
The event is raised when a data item is bound to a node in the control. This allows you to provide an event-handling method that performs a custom routine whenever this event occurs.
Raising an event invokes the event handler through a delegate. For more information, see Consuming Events.
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Raises the event of the control.
A that contains event data.
2.0.0.0
Method
System.Void
The event is raised when a node is expanded in the control. This allows you to provide an event-handling method that performs a custom routine whenever this event occurs.
If the property for a node is set to or , the event is also raised when that node is clicked in the control.
Raising an event invokes the event handler through a delegate. For more information, see Consuming Events.
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Raises the event of the control.
A that contains event data.
2.0.0.0
Method
System.Void
Sometimes, it is not practical to statically predefine the tree structure due to data size or custom content that depends on user input. Because of this, the control supports dynamic node population. When the property for a node is set to true, that node gets populated at run time when the node is expanded.
To populate a node dynamically, first set the property for the node to true. Next, define an event-handling method for the event that programmatically populates the node. A typical event-handling method retrieves node data from a data source, places the data into a node structure, and then adds the node structure to the collection of the node being populated. A node structure is created by adding objects to the collection of a parent node.
When the property for a node is set to true, the node must be populated dynamically. You cannot declaratively nest another node below it; otherwise, an error will occur on the page.
Supported browsers (Microsoft Internet Explorer 4.0-compatible browsers and later) can also take advantage of client-side node population. When enabled, this allows the control to populate a node on the client dynamically when that node is expanded, which prevents the need to post back to the server. For more information on client-side node population, see .
Raising an event invokes the event handler through a delegate. For more information, see Consuming Events.
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Raises the event of the control.
A that contains event data.
2.0.0.0
Property
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
System.ComponentModel.DefaultValue(null)
System.ComponentModel.NotifyParentProperty(true)
System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
System.Web.UI.WebControls.TreeNodeStyle
To be added.
Use the property to control the appearance of the parent nodes in the control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively in the form , where is a property of the object (for example, ParentNodeStyle-ForeColor). The properties can also be set programmatically in the form (for example, ParentNodeStyle.ForeColor). Common settings usually include a custom background color, foreground color, font properties, and node spacing. Style properties are applied in the following order of precedence:
-
.
-
, , or , depending on the node type. If the collection is defined, it is applied at this time, overriding the other node style properties.
-
.
-
.
If you need to generate table of contents-style navigation menus where nodes at a certain level should have the same appearance, regardless of whether they have child nodes, you might consider using the property instead of setting the individual style properties.
Gets a reference to the object that allows you to set the appearance of parent nodes in the control.
2.0.0.0
Property
System.ComponentModel.DefaultValue(/)
System.Char
To be added.
The property contains a delimiter-separated list of node values that form a path from the root node to the current node. Use the property to specify the delimiter character that is used to separate the node values. This value is commonly used when parsing the list for the individual values.
Depending on the text that is displayed in the control, the delimiter character might need to be changed to prevent any conflicts. For example, if you set the delimiter character to a comma, the displayed text should not contain any commas; otherwise, the property cannot be parsed accurately.
The value of this property is stored in view state.
Gets or sets the character that is used to delimit the node values that are specified by the property.
2.0.0.0
Method
2.0.0.0
System.Void
The method is a helper method that is called by the control to bind the specified data source to the control.
Creates all the nodes based on the data source.
Property
System.ComponentModel.DefaultValue(true)
System.Boolean
To be added.
Sometimes, it is not practical to statically predefine the tree structure due to data size or custom content that depends on user input. Because of this, the control supports dynamic node population. When the property for a node is set to true, that node gets populated at run time when the node is expanded.
In addition to populating nodes on demand, it is possible to populate the nodes directly on a supported client browser. When the property is set to true, a service is called from the client to populate the tree nodes, which eliminates the need to post back to the server. Otherwise, the control posts back to the server to populate the nodes.
The property must also be set to true in order for the property to be set to true.
To populate a node on the client, first set the property to true and then set the property for the node to true. Next, define an event-handling method for the event that programmatically populates the node. A typical event-handling method retrieves node data from a data source, places the data into a node structure, and then adds the node structure to the collection of the node being populated. You create a node structure by adding objects to the collection of a parent node.
When the property for a node is set to true, the node must be populated dynamically. You cannot declaratively nest another node below it; otherwise, an error will occur on the page.
The client-side node population feature is supported in browsers that support callback scripts. To check whether a browser supports callback scripts access, use the property of the class. You can access the instance of the class for the current request through the property of the class.
The value of this property is stored in view state.
Gets or sets a value indicating whether node data is populated on demand from the client.
2.0.0.0
Method
System.Void
To be added.
The method is a helper method for the method.
Raises the callback event using the specified arguments.
The argument for the callback handler in the method.
2.0.0.0
Method
System.Void
The page passes the value of the parameter to the method of the control that implements the interface. This control also renders the HTML element that causes the postback event to occur. If the control renders client-side script to post back to the server, the argument from the script is passed in the parameter. If the postback event is caused by a simple submit to the server, the parameter is null.
The method provides the functionality for many events that are implemented by HTML and Web server controls.
Enables the control to process an event that is raised when a form is posted to the server. The method is a helper method for the method.
A string that represents an optional event argument to pass to the event handler.
2.0.0.0
Method
System.Void
Change events for the control are raised from the method.
Signals the control to notify the ASP.NET application that the state of the control has changed.
2.0.0.0
Method
System.Void
The method is used primarily by control developers.
Renders the HTML opening tag of the control to the specified writer.
An that represents the output stream to render HTML content on the client.
2.0.0.0
Method
2.0.0.0
System.Void
Use the method to render the nodes in the control to the client.
Renders the nodes in the control.
The that represents the output stream used to write content to a Web page.
Method
System.Void
The method is used primarily by control developers.
Renders the HTML closing tag of the control to the specified writer.
An that represents the output stream to render HTML content on the client.
2.0.0.0
Property
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
System.ComponentModel.DefaultValue(null)
System.ComponentModel.NotifyParentProperty(true)
System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
System.Web.UI.WebControls.TreeNodeStyle
To be added.
Use the property to control the appearance of the root node in the control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively in the form , where is a property of the object (for example, RootNodeStyle-ForeColor). The properties can also be set programmatically in the form (for example, RootNodeStyle.ForeColor). Common settings usually include a custom background color, foreground color, font properties, and node spacing. Style properties are applied in the following order of precedence:
-
.
-
, , or , depending on the node type. If the collection is defined, it is applied at this time, overriding the other node style properties.
-
-
.
If you need to generate table of contents-style navigation menus where nodes at a certain level should have the same appearance, regardless of whether they have child nodes, you might consider using the property instead of setting the individual style properties.
Gets a reference to the object that allows you to set the appearance of the root node in the control.
2.0.0.0
Method
System.Object
To be added.
Saves the state of the control.
The server control's current view state; otherwise, null, if there is no view state associated with the control.
2.0.0.0
Property
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
System.ComponentModel.Browsable(false)
System.Web.UI.WebControls.TreeNode
To be added.
The text of a node in the control can be in one of two modes: selection mode and navigation mode. By default, a node is in selection mode. To put a node into navigation mode, set the property for the node to a value other than an empty string (""). To put a node into selection mode, set the property for the node to empty string ("").
When a node is in selection mode, the user can select a node by clicking on the text in the node. Use the property to determine which node is selected in the control.
A node cannot be selected when the control displays hyperlinks. When hyperlinks are displayed, the property always returns null.
When the user selects a different node in the control by clicking the text in the new node, the event is raised, by default. You can specify a different event by setting the property for the property. The following table lists the available options.
-
Selection action
Description
-
Toggles the node between expanded and collapsed. Raises the or event, as appropriate.
-
Raises no events when a node is selected.
-
Raises the event when a node is selected.
-
Raises both the and events when a node is selected. Nodes are only expanded, never collapsed.
The is not rendered for a node with its property set to TreeNodeSelectAction.None.
Gets a object that represents the selected node in the control.
2.0.0.0
Event
System.EventHandler
The event is raised when a node is selected in the control. This allows you to provide an event-handling method that performs a custom routine, such as updating the displayed content, whenever this event occurs.
You can optionally set the property for a node to specify which event is raised when that node is selected. The following table lists the available options.
-
Selection action
Description
-
Toggles the node between expanded and collapsed. Raises the or event, as appropriate.
-
Raises no events when a node is selected.
-
Raises the event when a node is selected.
-
Raises both the and events when a node is selected. Nodes are only expanded, never collapsed.
The is not rendered for a node with its property set to TreeNodeSelectAction.None.
The event is fired only on post back when a user clicks a node. The event is not fired if the property is changed programmatically.
For more information about handling events, see Consuming Events.
Occurs when a node is selected in the control.
2.0.0.0
Property
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
System.ComponentModel.DefaultValue(null)
System.ComponentModel.NotifyParentProperty(true)
System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
System.Web.UI.WebControls.TreeNodeStyle
To be added.
Use the property to control the appearance of the selected node in the control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively in the form , where is a property of the object (for example, SelectedNodeStyle-ForeColor). The properties can also be set programmatically in the form (for example, SelectedNodeStyle.ForeColor). Common settings usually include a custom background color, foreground color, font properties, and node spacing. Style properties are applied in the following order of precedence:
-
.
-
, , or , depending on the node type. If the collection is defined, it is applied at this time, overriding the other node style properties.
-
.
-
.
Gets the object that controls the appearance of the selected node in the control.
2.0.0.0
Property
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
System.ComponentModel.DefaultValue("")
System.ComponentModel.Browsable(false)
System.String
To be added.
The property provides a convenient way to determine the value of the selected node. This property simply returns the value of the property of the object that is referred to by the property. If no node is currently selected in the control, an empty string ("") is returned.
Gets the value of the selected node.
2.0.0.0
Method
System.Void
Use the method to indicate whether the specified is data-bound.
Allows a derived class to set whether the specified control is data-bound.
The to set.
true to set the node as data-bound; otherwise, false.
2.0.0.0
Method
System.Void
Use the method to specify the data item for the specified control.
Allows a derived class to set the data item for the specified control.
The to set.
The data item for the .
2.0.0.0
Method
System.Void
Use the method to set the data path for the specified control.
Allows a derived class to set the data path for the specified control.
The to set.
The data path for the .
2.0.0.0
Property
System.ComponentModel.DefaultValue(System.Web.UI.WebControls.TreeNodeTypes.None)
System.Web.UI.WebControls.TreeNodeTypes
To be added.
To provide multi-node selection support in the control, you can display check boxes next to the image for a node. Use the property to specify which node types will display a check box. For example, if this property is set to TreeNodeType.Parent, check boxes are displayed for each parent node in the tree. The following table lists the valid values for this property.
-
Node type
Description
-
TreeNodeType.All
Check boxes are displayed for all nodes.
-
TreeNodeType.Leaf
Check boxes are displayed for all leaf nodes.
-
TreeNodeType.None
Check boxes are not displayed.
-
TreeNodeType.Parent
Check boxes are displayed for all parent nodes.
-
TreeNodeType.Root
Check boxes are displayed for all root nodes.
The enumeration type that is used for the property is a flag enumeration, which allows you to combine values through bitwise operations. For example, to display check boxes for the parent and leaf nodes, use the bitwise OR operator to combine the TreeNodeType.Parent and TreeNodeType.Leaf values.
To determine which nodes have their check box selected, iterate through the nodes of the collection.
You can override the setting by setting the property for each node.
If you need to provide only single-selection support, consider using the property.
The value of this property is stored in view state.
Gets or sets a value indicating which node types will display a check box in the control.
2.0.0.0
Property
System.ComponentModel.DefaultValue(true)
System.Boolean
To be added.
Expansion node indicators are used to show whether a node is expanded, collapsed, or non-expandable. Use the property to specify whether the expansion node indicators are displayed in the control.
When the property is set to true, the control displays a plus sign (+) or minus sign (-) or a placeholder image next to a node to indicate whether the node is expandable, collapsible, or non-expandable, respectively. You can specify custom images by first setting the property to TreeViewImageSet.Custom, and then setting the , , and properties to the URLs of the custom images. If no images are specified, the default images are used.
The value of this property is stored in view state.
Gets or sets a value indicating whether expansion node indicators are displayed.
2.0.0.0
Property
System.ComponentModel.DefaultValue(false)
System.Boolean
To be added.
Use the property to specify whether the lines that are connecting child nodes to parent nodes are displayed. When this property is set to true, the control searches the Web-accessible folder that is specified by the property for the line images.
If the property is not set, the control will use the built-in, default images (20 x 20 pixels).
The value of this property is stored in view state.
Gets or sets a value indicating whether lines connecting child nodes to parent nodes are displayed.
2.0.0.0
Property
System.ComponentModel.Localizable(true)
System.String
To be added.
The property is a property that you can set to make a Web page more or less accessible. Web pages that contain content that repeats can provide for a mechanism for users of screen readers to skip the content from being read aloud.
The control provides the property as a way for the entire control to be skipped by screen readers. If the property is set, an invisible image with alternate text is rendered, giving the user the option to jump to the end of the control. Screen readers read the alternate text aloud, while the image occupies only one pixel space. For pixel-precise control over the rendering of the page, set the property to an empty string ("") and provide your own mechanism to skip the tree.
The property is set to the empty string by default, which makes screen readers not skip the control.
The value of this property is stored in view state.
The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and ASP.NET Globalization and Localization.
Gets or sets a value that is used to render alternate text for screen readers to skip the content for the control.
2.0.0.0
Method
2.0.0.0
System.String
The control implements the interface and uses the to retrieve data and the method to return the retrieved data to the control.
Returns the result of a callback event that targets a control.
The results of the callback.
Method
2.0.0.0
System.Void
To be added.
Control developers should override the method.
Raises the callback event using the specified arguments.
The argument for the callback handler in the method.
Method
2.0.0.0
System.Boolean
Control developers should override the method.
Processes postback data for the control.
true, if the control's state changes as a result of the postback event; otherwise, false.
The key identifier for the control.
The collection of all incoming name values.
Method
2.0.0.0
System.Void
Control developers should override the method.
Signals the control to notify the ASP.NET application that the state of the control has changed.
Method
2.0.0.0
System.Void
Control developers should override the method.
Enables the control to process an event that is raised when a form is posted to the server.
A string that represents an optional event argument to pass to the event handler.
Property
System.Web.UI.HtmlTextWriterTag
To be added.
The property allows the output stream to write the appropriate HTML mark-up for the control.
Gets the value for the control.
2.0.0.0
Property
System.ComponentModel.DefaultValue("")
System.String
To be added.
Use the property to specify the window or frame in which to display the Web content that is linked to a node when that node is clicked.
The property renders as a target attribute. The target attribute on anchor elements is not allowed in the XHTML 1.1 document type definition. Do not set the property, if the rendered output for the must be XHTML 1.1 compliant. For more information, see ASP.NET and XHTML Compliance.
When creating accessible Web pages, you should avoid using the property to target another window. For more information, see ASP.NET Controls and Accessibility.
The value of this property is stored in view state.
Gets or sets the target window or frame in which to display the Web page content that is associated with a node.
2.0.0.0
Method
System.Void
The method is overridden to mark the starting point to begin tracking and saving changes to the control as part of the view state for the control.
Tracks view-state changes to the control so that they can be stored in the object for the control. This is accessible through the property.
2.0.0.0
Event
System.Web.UI.WebControls.TreeNodeEventHandler
The event is raised when a check box in the control changes state between posts to the server. This allows you to provide an event-handling method that performs a custom routine, such as updating a database or the displayed content, whenever this event occurs.
Even though the event is fired on post back, changing a check box does not cause a post back.
For more information about handling events, see Consuming Events.
Occurs when a check box in the control changes state between posts to the server.
2.0.0.0
Event
System.Web.UI.WebControls.TreeNodeEventHandler
The event is raised when a node is collapsed in the control. This allows you to provide an event-handling method that performs a custom routine whenever this event occurs.
For more information about handling events, see Consuming Events.
Occurs when a node is collapsed in the control.
2.0.0.0
Event
System.Web.UI.WebControls.TreeNodeEventHandler
The event is raised when a data item is bound to a node in the control. This allows you to provide an event-handling method that performs a custom routine whenever this event occurs.
For more information about handling events, see Consuming Events.
Occurs when a data item is bound to a node in the control.
2.0.0.0
Event
System.Web.UI.WebControls.TreeNodeEventHandler
The event is raised when a node is expanded in the control. This allows you to provide an event-handling method that performs a custom routine whenever this event occurs.
If the property for a node is set to TreeNodeSelectAction.Expand or TreeNodeSelectAction.SelectExpand, the event is also raised when that node is clicked in the control.
For more information about handling events, see Consuming Events.
Occurs when a node is expanded in the control.
2.0.0.0
Event
System.Web.UI.WebControls.TreeNodeEventHandler
Sometimes, it is not practical to statically predefine the tree structure due to data size or custom content that depends on user input. Because of this, the control supports dynamic node population. When the property for a node is set to true, that node gets populated at run time when the node is expanded.
To populate a node dynamically, first set the property for the node to true. Next, define an event-handling method for the event that populates the node programmatically. A typical event-handling method retrieves node data from a data source, places the data into a node structure, and then adds the node structure to the collection of the node being populated. A node structure is created by adding objects to the collection of a parent node.
When the property for a node is set to true, the node must be populated dynamically. You cannot declaratively nest another node below it; otherwise, an error will occur on the page.
Supported browsers (Microsoft Internet Explorer 4.0-compatible browsers and later) can also take advantage of client-side node population. When enabled, this allows the control to populate a node dynamically on the client when that node is expanded, which prevents the need to post back to the server. For more information on client-side node population, see .
For more information about handling events, see Consuming Events.
Occurs when a node with its property set to true is expanded in the control.
2.0.0.0
Property
System.Boolean
To be added.
If the property is set to false, the control is not rendered.
Gets or sets a value indicating whether the control is rendered as UI on the page.
2.0.0.0