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

Using Custom Attributes Declaratively

Custom attributes can be added to a node by simply adding an HTML attribute to a RadTreeNode tag. Then access the attribute in server-side or client-side code. The example below defines a custom "ScientificName" attribute. The attribute is accessed in the server-side NodeClick event through the Attributes property.

RadTreeView Custom Attributes

<telerik:RadTreeView RenderMode="Lightweight" ID="RadTreeView1" runat="server" OnNodeClick="RadTreeView1_NodeClick">
        <telerik:RadTreeNode runat="server" ExpandMode="ClientSide" Text="Red Oak" ScientificName="Quercus rubra">
        <telerik:RadTreeNode runat="server" ExpandMode="ClientSide" Text="Eastern Red Cedar"
            ScientificName="Juniperus virginiana">
        <telerik:RadTreeNode runat="server" ExpandMode="ClientSide" Text="Lacebark Elm" ScientificName="Ulmus parvifolia ">
protected void RadTreeView1_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
    e.Node.Text = e.Node.Attributes["ScientificName"];
Protected Sub RadTreeView1_NodeClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs)
    e.Node.Text = e.Node.Attributes("ScientificName")
End Sub

The custom attribute's name should not be an HTML reserved word . Please see this article for more information.

See Also

In this article