Export (0) Print
Expand All

TreeNode.Text Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the text displayed for the node in the TreeView control.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

[LocalizableAttribute(true)] 
public string Text { get; set; }
/** @property */
public String get_Text ()

/** @property */
public void set_Text (String value)

public function get Text () : String

public function set Text (value : String)

Property Value

The text displayed for the node in the TreeView control. The default is an empty string ("").

Use the Text property to specify or determine the text that is displayed for the node in the TreeView control.

NoteNote

If the Text property contains a null reference (Nothing in Visual Basic), the get accessor returns the value of the Value property. If the Value property, in turn, contains a null reference (Nothing in Visual Basic), Empty is returned.

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 LocalizableAttribute and ASP.NET Globalization and Localization.

TopicLocation
How to: Add or Delete TreeView Node Elements (Visual Studio)Building ASP .NET Web Applications in Visual Studio

The following code example demonstrates how to use the Text property to specify the text for a node.


<%@ Page Language="C#" %>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeView Declarative Syntax Example</h3>
      
      <asp:TreeView id="SampleTreeView" 
        runat="server">
         
        <Nodes>
        
          <asp:TreeNode Value="Home" 
            NavigateUrl="Home.aspx" 
            Text="Home"
            Target="Content" 
            Expanded="True">
             
            <asp:TreeNode Value="Page 1" 
              NavigateUrl="Page1.aspx" 
              Text="Page1"
              Target="Content">
               
              <asp:TreeNode Value="Section 1" 
                NavigateUrl="Section1.aspx" 
                Text="Section 1"
                Target="Content"/>
                 
            </asp:TreeNode>              
            
            <asp:TreeNode Value="Page 2" 
              NavigateUrl="Page2.aspx"
              Text="Page 2"
              Target="Content">
               
            </asp:TreeNode> 
            
          </asp:TreeNode>
        
        </Nodes>
        
      </asp:TreeView>

    </form>
  </body>
</html>


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft