简体   繁体   English

以编程方式更改ASP.NET C#选项卡标题文本

[英]Programmatically Changing ASP.NET C# Tab Title Text

I am trying to change the Tab text when I navigate to a page. 当我导航到页面时,我试图更改“标签”文本。 I have many many pages so I don't want to go to each page and add a title control. 我的页面很多,所以我不想转到每个页面并添加标题控件。 Instead I am trying to change the MasterPage.master.cs so I only have to add that one bit of code. 相反,我试图更改MasterPage.master.cs,所以我只需要添加那一点代码。

The following code is close to what I would like MasterPage.master.cs: 以下代码接近我想要的MasterPage.master.cs:

Page.Header.Title = this.Page.ToString(): Page.Header.Title = this.Page.ToString():

This would display "ASP.shipping_aspx" (page name is Shipping.aspx) but I would like it to display "Shipping". 这将显示“ ASP.shipping_aspx”(页面名称为Shipping.aspx),但是我希望它显示“ Shipping”。

How can I programmatically change the tab title text so that it changes whenever I navigate to a new page? 如何以编程方式更改选项卡标题文本,以便在导航到新页面时更改它?

string title = this.Page.ToString().Split('.')[1].Split('_')[0];

Page.Header.Title = char.ToUpper(title[0]) + title.Substring(1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM