【问题标题】:<title></title> tag occurs two time on Page<title></title> 标签在页面上出现两次
【发布时间】:2012-03-20 10:30:13
【问题描述】:

我已动态设置页面标题。当我查看&lt;title&gt; 标记出现两次的页面源时,一个标记具有我在&lt;head&gt; 开始下方动态设置的值,但另一个在&lt;/head&gt; 之前是空白的。 在母版页头标签中包含以下代码:

<head runat="server">
<asp:ContentPlaceHolder ID="pageTitle" runat="server"></asp:ContentPlaceHolder>

<asp:ContentPlaceHolder ID="head" runat="server">       
</asp:ContentPlaceHolder>

</head>

在页面上我已将页面标题设置为:

 var title = new HtmlTitle {Text = title1};
  var h1Tag = Utilities.FindControlRecursive(this, "pageTitle");// by the find the pageTitle control 
   if (h1Tag != null)
   {
      h1Tag.Controls.Add(title);
    }

我无法弄清楚为什么标题出现两次。 我还想把元关键字、元描述和标题放在&lt;head&gt; 标签的下面。

【问题讨论】:

    标签: c# asp.net master-pages


    【解决方案1】:

    ASP .Net 也设置(添加)页面的标题,即使没有价值。尝试使用Page.Title动态设置标题。

    【讨论】:

    • 我已经尝试过了,但它在结束 head 标签之前添加了 标签。但我希望 就在开头的 head 标签下方。
    • 这种行为很奇怪,确定吗?
    • 是的,我得到了解决方案。只需在母版页上添加默认的 test 任何您想要放置的位置,只需在您想要动态设置的页面上重置它。
    猜你喜欢
    • 2015-02-27
    • 2014-01-31
    • 2013-03-15
    • 1970-01-01
    • 1970-01-01
    • 2013-01-30
    • 1970-01-01
    • 1970-01-01
    • 2017-06-20
    相关资源
    最近更新 更多