我已經使用主頁創建了一個內容頁面。如何在內容頁面設置標題asp.net
在母版頁中,我創建了以下標籤標題:
<head id="Head1" runat="server">
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
</head>
中的內容頁面,如下設置:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (String.IsNullOrEmpty(Request.QueryString["PatientRegistrationKey"]))
{
// ....
}
else
{
this.Page.Title = "My New Title";
//....
}
}
雖然我也是在運行時將主頁作爲波紋管:
protected void Page_PreInit(Object sender, EventArgs e)
{
if (String.IsNullOrEmpty(Request.QueryString["PatientRegistrationKey"]))
this.MasterPageFile = "~/MasterPages/A.master";
else
this.MasterPageFile = "~/MasterPages/B.master";
}
在瀏覽器中打開此頁面時,我得到以下標題:
http://localhost:3562/?PatientRegistrationKey=0
- 我的新標題
的變化請指點,使應該只有我的新標題標題內,沒有任何額外的像查詢字符串等
任何幫助,將不勝感激。
你要爲標題在第一if條件...? – deostroll 2014-05-12 08:38:59