Tab Strip on Master Page

2 posts, 0 answers
  1. Raymond
    Raymond avatar
    13 posts
    Member since:
    Sep 2013

    Posted 09 Jan 2015 Link to this post

    I have created a sample web site that consists of a Master Page with a RadTabStrip and three tabs that link to three content pages ==> PageOne.aspx, PageTwo.aspx, and PageThree.aspx. The Master Page displays the current date/time which changes as each new tab is clicked.

    My question, is there a way to have the new pages load without having to reload the Master Page, using Ajax or something. In this simple example, the date / time would not update as each new tab is clicked.

    If so, how would I do this.  How would I change this.

    <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title>Untitled Page</title>
        <asp:ContentPlaceHolder id="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
       <form id="form1" runat="server">
       <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
       </telerik:RadScriptManager>
       <div>
          <asp:Label ID="lblDateTime" runat="server" Text="Label"></asp:Label>
       </div>
       <div>
          <telerik:RadTabStrip ID="RadTabStrip" runat="server">
             <Tabs>
                <telerik:RadTab Text="Page One" NavigateUrl="PageOne.aspx" Value="PageOne.aspx"></telerik:RadTab>
                <telerik:RadTab Text="Page Two" NavigateUrl="PageTwo.aspx" Value="PageTwo.aspx"></telerik:RadTab>
                <telerik:RadTab Text="Page Three" NavigateUrl="PageThree.aspx" Value="PageThree.aspx"></telerik:RadTab>
             </Tabs>
          </telerik:RadTabStrip>
          <br /><br />
          <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
             
          </asp:ContentPlaceHolder>
       </div>
       </form>
    </body>
    </html>
     
    <%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="PageOne.aspx.vb" Inherits="PageOne" %>
     
    <%@ MasterType VirtualPath="~/MasterPage.master" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
       <b>Page One</b>
    </asp:Content>
     
    <%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="PageTwo.aspx.vb" Inherits="PageOne" %>
     
    <%@ MasterType VirtualPath="~/MasterPage.master" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
       <b>Page Two</b>
    </asp:Content>
     
    <%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="PageThree.aspx.vb" Inherits="PageOne" %>
     
    <%@ MasterType VirtualPath="~/MasterPage.master" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
       <b>Page Three</b>
    </asp:Content>
     
    On Page Load
    Public Sub SetCurrentTab()
          Dim tab As RadTab = RadTabStrip.FindTabByValue(System.IO.Path.GetFileName(Request.Url.ToString()))
     
          If tab IsNot Nothing Then
             tab.Selected = True
          End If
       End Sub
    End Class

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 14 Jan 2015 Link to this post

    Hеllo,

    I would like to clarify that due to the Asp.Net concept the master page will be loaded on each post-back. A possible solution to avoid printing the current date and time on each post-back you can do that only when the page is initially loaded.
    Please refer to code snippet below:
    //code behind
    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
               //your code goes here if you want to be executed only on page initial load.
            }
        }



    Regards,
    Boyan Dimitrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top