单击选项卡时如何更改页面标题?

时间:2017-02-25 23:28:00

标签: c# asp.net page-title

我有aspx页面和代码如下:

<%@ Page Title="" Language="C#" MasterPageFile="~/Autheticated.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="PIWorks.PIWebNext.Pages.Default" %>

<%@ Import Namespace="System.Web.Optimization" %>
<asp:Content runat="server" ID="Content1" ContentPlaceHolderID="UxContentHead">
    <title>Public Reports</title> // default selected tab
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="UxContentMain" runat="server">
    <div ng-controller="homeController" style="height: 100%; width: 100%; position: relative;">
        <div pi-tab-view name="MainTabs" selected-tab-name="TabPublic">
            <div pi-tab name="TabDashBoard" is-visible="TabDashBoardIsVisible">
                <div class="tab-head">Dashboards</div> // dash tab
            </div>
            <div pi-tab name="TabPublic">
                <div class="tab-head">Public Reports</div>  // public report tab
            </div>
            <div pi-tab name="TabPrivate">
                <div class="tab-head">Private Reports</div>  // private report tab
            </div>
            <div pi-tab name="TabFavorite">
                <div class="tab-head">Favorite Reports</div>  //favorite report tab
            </div>
        </div>
    </div>
</asp:Content>

我想点击私人报告标签(或其他标签页)标题时应该更改

for example : click private report => Page Title : Private Reports
                    favorite report => Page Title : Favorite Reports
                    dashboard => Page Title : Dashboards

我该怎么办?

2 个答案:

答案 0 :(得分:1)

您可以使用JavaScript执行此操作:

document.title =&#34;我的标题&#34 ;;

答案 1 :(得分:1)

有一些方法可以实现这一目标。您可以使用上面提到的Javascript。或者JQuery。甚至是aspx本身。以下是JQuery中的一个示例:

<强> JQuery的

$(document).on("click", ".tab-head", function trigger(){
  if(this.text() == "Public Reports"){
     document.title = "Public Reports";
  }
  else if...
});