I agree to the

Anchor tag in form label using Html.LabelFor in MVC3

I would like to do something like

<label for="AgreedToTherms"> I agree to the <a href="therms-and-conditions">Therms and conditions</a> </label> 

Is this allowed by html standards? Using the standard Html helper in a view

 @Html.LabelFor(model => model.AgreedToTherms) 

I tried using html in the shortcut, but this text gets html encoding

+6
source share
1 answer

You can do this:

 @MvcHtmlString.Create(HttpUtility.HtmlDecode( Html.LabelFor(m=>m.AgreedToTherms).ToString())) 

(OR)

 @Html.Raw(@HttpUtility.HtmlDecode( Html.LabelFor(m=>m.AgreedToTherms).ToString())) 
+11
source

Source: https://habr.com/ru/post/910802/


All Articles