gpt4 book ai didi

html - MVC2 : Is there an Html Helper for raw Html?

转载 作者:太空狗 更新时间:2023-10-29 15:24:34 25 4
gpt4 key购买 nike

是否有一个 Html 助手可以简单地接受并返回原始 html?而不是做这样丑陋的事情:

<% if (Model.Results.Count > 0) { %><h2>Results</h2><% } %>

我想做这样的事情:

 <% if (Model.Results.Count > 0) { Html.RawHtml("<h2>Results</h2>") } %>

不是很干净,但我认为这是一个改进。有这样的东西吗?还是有比使用 Html 助手更好的替代方法来从这些转义字符中输出原始 html?

最佳答案

对于 MVC2:

<%: MvcHtmlString.Create("<h2>Results</h2>") %>

在这里找到:

store and display html tags in MVC

关于html - MVC2 : Is there an Html Helper for raw Html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2169805/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com