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

Persisting TreeView Settings

  • Island
    • Zanzibar
    • Mauritius
    • Maldives
      • Weekend Package
      • 1 Week Package
      • 2 Week Package

In this example you can see how to preserve the Selected and Checked TreeView nodes using the Telerik ASP.NET Persistence Framework.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page Title="" Language="C#"  AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
</head>

<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadPersistenceManager runat="server" ID="RadPersistenceManager1">
        <PersistenceSettings>
            <telerik:PersistenceSetting ControlID="RadTreeView1" />
        </PersistenceSettings>
    </telerik:RadPersistenceManager>
    <asp:Label ID="Label1" runat="server"></asp:Label>
    <div class="demo-container size-narrow">
        <div class="demo-settings">
            <telerik:RadButton RenderMode="Lightweight" ID="SaveButton" runat="server"  Text="Save state" OnClick="SaveButton_Click" />
            <telerik:RadButton RenderMode="Lightweight" ID="ResetButton" runat="server"  Text="Reset state" OnClick="ResetButton_Click" />
            <telerik:RadButton RenderMode="Lightweight" ID="LoadButton" runat="server"  Text="Load state" OnClick="LoadButton_Click" />
        </div>
        <telerik:RadTreeView RenderMode="Lightweight" runat="Server" ID="RadTreeView1"  EnableDragAndDrop="false" CheckBoxes="true">
            <Nodes>
                <telerik:RadTreeNode runat="server" Text="Island" Expanded="true" AllowDrag="false"
                    AllowDrop="false">
                    <Nodes>
                        <telerik:RadTreeNode runat="server" Text="Zanzibar" AllowDrag="false">
                            <Nodes>
                                <telerik:RadTreeNode runat="server" Text="Weekend Package" AllowDrop="false" Value="1999">
                                </telerik:RadTreeNode>
                                <telerik:RadTreeNode runat="server" Text="1 Week Package" AllowDrop="false" Value="2999">
                                </telerik:RadTreeNode>
                                <telerik:RadTreeNode runat="server" Text="2 Week Package" AllowDrop="false" Value="3999">
                                </telerik:RadTreeNode>
                            </Nodes>
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode runat="server" Text="Mauritius" AllowDrag="false">
                            <Nodes>
                                <telerik:RadTreeNode runat="server" Text="Weekend Package" AllowDrop="false" Value="2999">
                                </telerik:RadTreeNode>
                                <telerik:RadTreeNode runat="server" Text="1 Week Package" AllowDrop="false" Value="3999">
                                </telerik:RadTreeNode>
                                <telerik:RadTreeNode runat="server" Text="2 Week Package" AllowDrop="false" Value="4999">
                                </telerik:RadTreeNode>
                            </Nodes>
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode runat="server" Text="Maldives" Expanded="true" AllowDrag="false">
                            <Nodes>
                                <telerik:RadTreeNode runat="server" Text="Weekend Package" AllowDrop="false" Value="3999">
                                </telerik:RadTreeNode>
                                <telerik:RadTreeNode runat="server" Text="1 Week Package" AllowDrop="false" Value="4999">
                                </telerik:RadTreeNode>
                                <telerik:RadTreeNode runat="server" Text="2 Week Package" AllowDrop="false" Value="5999">
                                </telerik:RadTreeNode>
                            </Nodes>
                        </telerik:RadTreeNode>
                    </Nodes>
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeView>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance