使用asp.net文字和占位符作为元标记
我正在尝试使用literal和placeholder来实现母版页,该母版页允许添加描述或关键字等元标记。我正在使用以下代码使用asp.net文字和占位符作为元标记,asp.net,tags,literals,meta,Asp.net,Tags,Literals,Meta,我正在尝试使用literal和placeholder来实现母版页,该母版页允许添加描述或关键字等元标记。我正在使用以下代码 Just for further info: " is used for double quotes / is slash (/) <!-- description in master page --> <asp:Literal ID="descriptionStart" runat="server" Text="&l
Just for further info:
" is used for double quotes
/ is slash (/)
<!-- description in master page -->
<asp:Literal ID="descriptionStart" runat="server" Text="<meta name="description" content="test" />
<asp:ContentPlaceHolder ID="metaDescription" runat="server" />
<asp:Literal ID="descriptionEnd" runat="server" Text="" />"/>
<!-- 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 -->
仅供参考:
“用于双引号
/;是斜杠(/)
在我的内容页中,我添加了如下描述:
这是一个测试描述
IE视图代码显示:
看起来ASP.Net正在为lietrals添加换行符。是否可以将描述显示在与meta description标记相同的行上
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 -->
根据我收到的一条评论,我修改了母版页的代码。它将占位符括在单引号中。
以下是更改后IE视图代码的输出:
基本上,您已经添加了换行符,因为您的三个控件都从一个新行开始。将它们放在一行中,这取决于您的编码
我相信你不需要文字,你试过只写开头和结尾标签吗?很高兴它对你有用。