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 がリトラルに改行を追加しているようです。説明をメタ説明タグと同じ行に表示することはできますか?

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

基本的に、3 つのコントロールがそれぞれ新しい行で始まるため、改行を追加しました。それを行う必要があるエンコーディングに応じて、それらをすべて1行に並べて配置します。

リテラルは必要ないと思いますが、開始タグと終了タグだけを書き込もうとしましたか?

于 2013-07-02T13:21:45.353 に答える