我想完成类似的事情
<label for="AgreedToTherms">
I agree to the <a href="therms-and-conditions">Therms and conditions</a>
</label>
根据html标准,这是允许的吗?
在 View 中使用标准HTML助手
@Html.LabelFor(model => model.AgreedToTherms)
我试图使用在labeltext内添加html,但是此文本获得了html编码
最佳答案
您可以这样做:
@MvcHtmlString.Create(HttpUtility.HtmlDecode(
Html.LabelFor(m=>m.AgreedToTherms).ToString()))
(或者)
@Html.Raw(@HttpUtility.HtmlDecode(
Html.LabelFor(m=>m.AgreedToTherms).ToString()))
关于asp.net-mvc-3 - 在MVC3中使用Html.LabelFor在表单标签中的 anchor 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9721234/