System.Web.UI.WebControls.TreeView.SelectedNode Property

Gets a System.Web.UI.WebControls.TreeNode object that represents the selected node in the System.Web.UI.WebControls.TreeView control.

Syntax

[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.Browsable(false)]
public TreeNode SelectedNode { get; }

Value

Documentation for this section has not yet been entered.

Remarks

The text of a node in the System.Web.UI.WebControls.TreeView 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 TreeNode.NavigateUrl property for the node to a value other than an empty string (""). To put a node into selection mode, set the TreeNode.NavigateUrl 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 TreeView.SelectedNode property to determine which node is selected in the System.Web.UI.WebControls.TreeView control.

Note:

A node cannot be selected when the System.Web.UI.WebControls.TreeView control displays hyperlinks. When hyperlinks are displayed, the TreeView.SelectedNode property always returns null.

When the user selects a different node in the System.Web.UI.WebControls.TreeView control by clicking the text in the new node, the TreeView.SelectedNodeChanged event is raised, by default. You can specify a different event by setting the TreeNode.SelectAction property for the property. The following table lists the available options.

TreeNodeSelectAction.Expand

Toggles the node between expanded and collapsed. Raises the TreeView.TreeNodeExpanded or TreeView.TreeNodeCollapsed event, as appropriate.

TreeNodeSelectAction.None

Raises no events when a node is selected.

TreeNodeSelectAction.Select

Raises the TreeView.SelectedNodeChanged event when a node is selected.

TreeNodeSelectAction.SelectExpand

Raises both the TreeView.SelectedNodeChanged and TreeView.TreeNodeExpanded events when a node is selected. Nodes are only expanded, never collapsed.

Note:

The TreeView.HoverNodeStyle is not rendered for a node with its TreeNode.SelectAction property set to TreeNodeSelectAction.None.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0