How to: Find a Node by Its Text

This example demonstrates how to find a node by its text on the client side.

In the example we use the GetNodeByText(text) method to search for the required node. If a node has been found, the code iterates through parent nodes to expand them using the SetExpanded(value) method. After that the found note is selected using the SetSelectedNode(node) method. Note, that the ASPxTreeView's AllowSelectNode property is set to true to allow node selection.

View Example

function FindNode(s, e) {

    //Check the input data
    if (textbox.GetText()==''){
        alert('Please, input name of a node');
    if (treeview.GetNodeByText(textbox.GetText()) == null){
        alert('The ' + textbox.GetText() + ' node was not found');
    var node = treeview.GetNodeByText(textbox.GetText());

    //Iterate through the parent nodes to expand them
    var nodesparent = node.parent;
    while(nodesparent != null) {
        nodesparent = nodesparent.parent

    //Select the found node
<dx:ASPxTreeView ID="ASPxTreeView1" runat="server" ClientInstanceName="treeview" DataSourceID="XmlDataSource1" AllowSelectNode="True">
<br />
<dx:ASPxLabel ID="ASPxLabel1" runat="server" Text="Input the node's text (e.g. 'News')">
<dx:ASPxTextBox ID="ASPxTextBox1" runat="server" ClientInstanceName="textbox" Width="170px">
<br />
<dx:ASPxButton ID="ASPxButton1" runat="server" ClientInstanceName="searchbutton"
    Text="Find" AutoPostBack="False">
    <ClientSideEvents Click="FindNode"/>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/MenuTabbedMenu.xml"
    OnTransforming="XmlDataSource1_Transforming" XPath="/mainmenu/item">