【问题标题】:use asp.net literal and place holder for meta tag使用 asp.net 文字和占位符作为元标记
【发布时间】:2013-07-02 13:02:05
【问题描述】:

我正在尝试使用文字和占位符来实现允许添加元标记(例如描述或关键字)的母版页。我正在使用以下代码。

Just for further info:
" is used for double quotes
/ is slash (/)


<!-- description in master page -->
<asp:Literal ID="descriptionStart" runat="server" Text="<meta name=&quot;description&quot; content=&quot;test" />
<asp:ContentPlaceHolder ID="metaDescription" runat="server" />
<asp:Literal ID="descriptionEnd" runat="server" Text="&quot; &#47;>"/>
<!-- end of description -->


In my content page I add description as follows:
<asp:Content ID="metaDescription" ContentPlaceHolderID="metaDescription" runat="server">
This is a test description
</asp:Content>


IE View code shows this:
<!-- description in master page -->
<meta name="description" content="

This is a test description

" />
<!-- end of description -->

看起来 ASP.Net 正在为 Lietrals 添加换行符。是否可以在元描述标签的同一行显示描述?

Based on one comment I received Alexander, I modified the code for master page.  It's enclosing placeholder in single quotes.
<!-- description -->
<meta name="description" content='<asp:ContentPlaceHolder ID="metaDescription" runat="server" />' />
<!-- end of description -->

Here is the output of IE view code after the change:
<!-- description -->
<meta name="description" content='This is a test description' />
<!-- end of description -->

【问题讨论】:

  • 很高兴它对你有用。

标签: asp.net tags literals meta


【解决方案1】:

基本上,您已经添加了换行符,因为您的三个控件每个都从新行开始。将它们全部放在一行中,具体取决于您应该执行的编码。

我相信你不需要文字,你试过只写开始和结束标签吗?

【讨论】:

    猜你喜欢
    • 2012-11-09
    • 2014-08-24
    • 1970-01-01
    • 2019-08-17
    • 2017-06-25
    • 2012-11-09
    • 1970-01-01
    • 1970-01-01
    • 2013-09-28
    相关资源
    最近更新 更多