I am using DropDownList in MVC Razor and I am having problems with automatic HTML encoding. My code looks like this:
@Html.DropDownList("MyList", Model.DropdownNamesAndValues)
This works just fine, except that the property SelectListItem.Textin the list DropdownNamesAndValuesmay contain HTML bold or italic tags. Currently, they appear literally in a drop-down list (e.g. <i>hello</i> world). I would like to know how to do this:
- How to apply @ Html.Raw to each of the properties
SelectListItem.Text? - Otherwise, is there an easy way to simply remove the HTML tags instead? In principle, nothing, instead of showing them literally as they are at present.
source
share