0

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

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 -->
4

1 回答 1

0

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

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

于 2013-07-02T13:21:45.353 回答