HTML:
<meta name="description" runat="server" id="MetaDescription" content="" />
隐藏代码:
MetaDescription.Attributes["content"] = ThisBlog.MetaDescription;
这呈现为:
<meta id="HeadContent_MetaDescription" name="description" content="My page description"></meta>
As per 这个答案它不需要有 ID 属性,并以/>
.
我怎样才能让它以这种方式渲染?
我仍在使用 .net 3.5,但将其放入 Page_Load 中,它将执行您需要的操作:
HtmlMeta keywords = new HtmlMeta();
keywords.Name = "keywords";
keywords.Content = "one two trhee;
Header.Controls.Add(keywords);
PS:示例是关键字标签,但结果是相同的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)