New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Using Custom Attributes Server-side

Access attributes through the RadTreeNode Attributes collection by specifying a key name:

node.Attributes["MyCustomAttributeKey"] = "Some value";
node.Attributes("MyCustomAttributeKey") = "Some value"

The example below iterates the Attributes collection of a selected node and displays the key names and values in a RadTextBox.

RadTreeView Custom Attributes

<telerik:RadTreeView RenderMode="Lightweight" ID="RadTreeView1" runat="server" OnNodeClick="RadTreeView1_NodeClick"
        <telerik:RadTreeNode runat="server" Text="Alpine Parka" ProductNumber="AP0234" ProductColor="Blue"
        <telerik:RadTreeNode runat="server" Text="Expedition Parka" ProductNumber="EP3456"
            ProductColor="Red" Size="M">
        <telerik:RadTreeNode runat="server" Text="Goosedown Jacket" ProductNumber="GJ6549"
            ProductColor="Yellow" Size="L">

        protected void RadTreeView1_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
            foreach (string key in e.Node.Attributes.Keys)    
                tbNode.Text += key + ": " + e.Node.Attributes[key] + System.Environment.NewLine;    

        Protected Sub RadTreeView1_NodeClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs)
            For Each key As String In e.Node.Attributes.Keys
                tbNode.Text += key + ": " + e.Node.Attributes(key) + System.Environment.NewLine
        End Sub

In this article