如何获取 <%= Html.Encode(item.name) %>在页面元素的标题和头部
如何获取 <%= Html.Encode(item.name) %>在页面元素的标题和头部中,
我想使用内容占位符 - 标题内容和主要内容。然而,每次我尝试在这些元素中添加这些内容时,我都会收到一条错误消息,基本上说这是不允许的。
<h2>Performances for :<%= Html.Encode(item.venue) %></h2>
这就是我一直在做的事情,但它不起作用,
有人可以帮助我的查询吗,谢谢。
How do I get <%= Html.Encode(item.name) %> in the title and head of page elements
I am wanting to use this the content place holder - title content, and main content. However each time I try to add these in the those elements i get an error basically saying this not allowed.
<h2>Performances for :<%= Html.Encode(item.venue) %></h2>
this is what I have been doing but it wont work
can somebody please help with my query, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许可以尝试不将
标记放入页面的
Maybe try it without putting
<h2>
tags into the<title>
section of the page.从
标记中删除
runat="server"
属性。它是 WebForms 美好时光留下的遗产,在 MVC 中没有任何可行的意义,有人忘记从默认模板中删除它。此外,如果
item
变量在母版页中不可用,您可以使用内容占位符,如果该变量是仅在视图中可用的视图模型的一部分,则该占位符将在每个视图中重新定义。Remove the
runat="server"
attribute from your<head>
tag. It's legacy left from the good ol' days of WebForms which has no any viable meaning in MVC that someone forgot to remove from the default template.Also if the
item
variable is not available in the masterpage you could use a content placeholder which will be redefined in each view if this variable is part of a view model which is only available in views.