<meta name="keywords" content='<asp:Literal ID="litMetaKeywords" runat="server" />'/>
<meta name="description" content='<asp:Literal ID="litMetaDescription" runat="server" />'/>
我在我正在使用的Web应用程序中找到了上面的代码。我收到以下错误
The name 'litMetaDescription' does not exist in the current context
和相同litMetaKeywords
。如果asp:literal不在此meta标记中,则该代码将正常工作。什么是元标记?有什么用?是什么导致我的错误?
将<asp:Literal>
标签放在content
属性内不会使其从后面的代码中访问。您可以使用受保护变量和内联代码的组合。
后面的代码:
protected string MetaKeywords;
protected string MetaDescription;
protected void Page_Load(object sender, EventArgs e)
{
MetaKeywords = "values for meta keywords";
MetaDescription = "values for meta description";
}
aspx:
<meta name="keywords" content='<%= MetaKeywords %>'/>
<meta name="description" content='<%= MetaDescription %>'/>
有关HTML元标记的更多信息,请参见此处。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句