When trying to use this
@Html.DisplayFor(m => m.someField, new { htmlAttributes = "class = someclass" })
the field, when rendered does not contain class someclass. I supposed its because its just writing out the text and there isn't a span element or anything to set the class on.
I'm really looking to set the id so that I can update it via js later on.
class needs to be
@class
This comment is valid
This comment is also valid
This solution worked for me (for example, when model is Url): Razor view to DisplayFor DataType.Url that opens in new window
"You could override the default template by adding a file in ..."