<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Persist Selected Tab in Cookie - Demo Code</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Path="~/cachable_scripts.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <div>
    
        <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" 
            Skin="Vista"
            OnClientTabSelected="onClientTabSelected" 
            OnClientLoad="onClientTabLoad">
            <Tabs>
                <telerik:RadTab Text="Popular Content" />
                <telerik:RadTab Text="Recent Content" />
                <telerik:RadTab Text="Favorites" />
                <telerik:RadTab Text="Search" />
                <telerik:RadTab Text="Shortest" />
            </Tabs>
        </telerik:RadTabStrip>
        <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0">
            <telerik:RadPageView runat="server">
                Just some popular content. <a href="ContentPage.aspx">Navigate to content</a> 
            </telerik:RadPageView>
            <telerik:RadPageView ID="RadPageView1" runat="server">
                Just some recent content. <a href="ContentPage.aspx">Navigate to content</a> 
            </telerik:RadPageView>
            <telerik:RadPageView ID="RadPageView2" runat="server">
                Just some favorite content. <a href="ContentPage.aspx">Navigate to content</a> 
            </telerik:RadPageView>
            <telerik:RadPageView ID="RadPageView3" runat="server">
                Just some search content. <a href="ContentPage.aspx">Navigate to content</a> 
            </telerik:RadPageView>
            <telerik:RadPageView ID="RadPageView4" runat="server">
                Just some short content. <a href="ContentPage.aspx">Navigate to content</a> 
            </telerik:RadPageView>
        </telerik:RadMultiPage>
    </div>
    <script type="text/javascript">
        var tabstrip;
        
        function onClientTabLoad(sender) {
            //Get reference to tabstrip
            tabstrip = sender;
        }

        function onClientTabSelected(sender, args) {
            //Persist selected tab text
            var tabText = args.get_tab().get_text();
            //Save text to a cookie using JavaScript
            saveTabIndex(tabText);
        }

        //pageLoad automatically called by ASPNET AJAX when page ready
        function pageLoad() {
            //Must do tab strip select here so that 
            //multipage is initialized and updated
            loadTabIndex(tabstrip);
        }
    </script>
    </form>
</body>
</html>
