2010-04-09 70 views
0

我已经使用主页创建了一个内容页面。如何在内容页面设置标题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 - 我的新标题

的变化请指点,使应该只有我的新标题标题内,没有任何额外的像查询字符串等

任何帮助,将不胜感激。

+0

你要为标题在第一if条件...? – deostroll 2014-05-12 08:38:59

回答

5

如果您未在页面上设置默认标题,页面将显示URL作为标题。 围棋设置在.aspx文件页面标题:

<%@ Page Language="C#" MasterPageFile="..." 
    AutoEventWireup="true" Title="My Default Title" %> 
+0

我还在<%@ Page ...指令中设置了内容页面中的标题。有同样的问题。 – user255795 2010-04-09 13:02:54

+0

它必须发生在你遗漏的一些代码中。在你的问题中没有迹象表明它会是什么。 – Codesleuth 2010-04-09 13:46:41

+0

有没有进一步的建议? – user255795 2010-04-16 07:51:33