我想完成像
这样的事情<label for="AgreedToTherms">
I agree to the <a href="therms-and-conditions">Therms and conditions</a>
</label>
这是否允许根据HTML标准? 在视图中使用标准的Html帮助器
@Html.LabelFor(model => model.AgreedToTherms)
我尝试使用在labeltext中添加html,但是这个文本获得了html编码
答案 0 :(得分:11)
你可以这样做:
@MvcHtmlString.Create(HttpUtility.HtmlDecode(
Html.LabelFor(m=>m.AgreedToTherms).ToString()))
(OR)
@Html.Raw(@HttpUtility.HtmlDecode(
Html.LabelFor(m=>m.AgreedToTherms).ToString()))