![](/img/trans.png)
[英]How to render HTML tags in Html.EditorFor in mvc 4 razor
[英]MVC 3 Razor Engine and Html Tags
Razor 视图引擎自动区分服务器代码和 Html 代码例如此代码工作得很好
@if (DateTime.Now.Year == 1983)
{
if (DateTime.Now.Month == 9)
{
<p>Wow, this month Shay is born!</p>
}
}
else
{
<p>It's the new millenium dude!</p>
}
但是如果我想在文本中显示 html 标签或锚标签,那么我应该使用什么转义字符?
就像上面的例子一样,我想显示这样的 else 消息
else
{
<p>It's the new <millenium> dude!</p>
}
使用常规的 HTML 转义序列: <millenium>
你必须使用
<p>It's the new <millenium$gt; dude!</p>
但这不是 Razor 问题,而是 HTML。 如果要显示<
或>
,则必须改用 HTML 实体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.