我想完成类似的事情
- <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编码
解决方法
你可以这样做:
- @MvcHtmlString.Create(HttpUtility.HtmlDecode(
- Html.LabelFor(m=>m.AgreedToTherms).ToString()))
(要么)
- @Html.Raw(@HttpUtility.HtmlDecode(
- Html.LabelFor(m=>m.AgreedToTherms).ToString()))