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

Persist State in Cookie

Current page:

Normally, the state of the accordion control would be lost when navigating between pages unless you programmatically persist it or use the PersistStateInCookie property. This example demonstrates the latter- just set the PersistStateInCookie property to true.

State restoring occurs before the PreRender event of RadPanelbar. You can access the SelectedItem by subscribing to the PreRender (DataBound if you use declarative datasources) event.

Please review the code sections for more details.

  • DefaultVB.aspx
  • DefaultVB.aspx.vb
  • styles.css
<%@ Page Language="vb" CodeFile="DefaultVB.aspx.vb" AutoEventWireup="true" Inherits="PanelBar.Examples.Functionality.PersistStateInCookie.DefaultVB" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<!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" />

    <div class="demo-container size-thin">
        <telerik:RadPanelBar RenderMode="Lightweight" runat="server" ID="RadPanelBar1" PersistStateInCookie="True" Width="100%"
            OnPreRender="RadPanelBar1_PreRender">
            <Items>
                <telerik:RadPanelItem Text="ASP.NET controls" Expanded="true">
                    <Items>
                        <telerik:RadPanelItem NavigateUrl="DefaultVB.aspx?page=menu" Text="RadMenu" />
                        <telerik:RadPanelItem NavigateUrl="DefaultVB.aspx?page=combobox" Text="RadComboBox" />
                        <telerik:RadPanelItem NavigateUrl="DefaultVB.aspx?page=panelbar" Text="RadPanelBar" />
                        <telerik:RadPanelItem NavigateUrl="DefaultVB.aspx?page=treeview" Text="RadTreeView" />
                    </Items>
                </telerik:RadPanelItem>
                <telerik:RadPanelItem Text="WinForms controls">
                    <Items>
                        <telerik:RadPanelItem Text="RadMenustrip" NavigateUrl="DefaultVB.aspx?page=menustrip" />
                        <telerik:RadPanelItem Text="RadTabStrip" NavigateUrl="DefaultVB.aspx?page=tabstrip" />
                        <telerik:RadPanelItem Text="RadToolStrip" NavigateUrl="DefaultVB.aspx?page=toolbarstrip" />
                    </Items>
                </telerik:RadPanelItem>
                <telerik:RadPanelItem Text="Other projects">
                    <Items>
                        <telerik:RadPanelItem Text="SiteFinity" NavigateUrl="DefaultVB.aspx?page=sitefinity" />
                        <telerik:RadPanelItem Text="Reporting" NavigateUrl="DefaultVB.aspx?page=reporting" />
                        <telerik:RadPanelItem Text="RadAjax" NavigateUrl="DefaultVB.aspx?page=ajax" />
                    </Items>
                </telerik:RadPanelItem>
            </Items>
        </telerik:RadPanelBar>
        <div class="qsf-result">
            <h2>Current page:</h2>
            <p>
                <asp:Literal runat="server" ID="Label1" /></p>
        </div>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance