I would like to accomplish something like
<label for="AgreedToTherms">
I agree to the <a href="therms-and-conditions">Therms and conditions</a>
</label>
Is this allowed according to html standards? Using the standard Html helper in a view
@Html.LabelFor(model => model.AgreedToTherms)
I tried to use add the html inside the labeltext but this text gets html encoded
You can do this way:
@MvcHtmlString.Create(HttpUtility.HtmlDecode(
Html.LabelFor(m=>m.AgreedToTherms).ToString()))
(OR)
@Html.Raw(@HttpUtility.HtmlDecode(
Html.LabelFor(m=>m.AgreedToTherms).ToString()))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With