Html.Label
and Html.LabelFor
helper methods do not support the htmlAttributes parameter like most of the other helpers do. I would like to set the class
however. Something like this:
Html.LabelFor(model => model.Name, new { @class = "control-label" })
Is there an easy way of extending Label/LabelFor without resorting to copying and extending the ILSpy disasm output of those methods?
You can easily extend the label by creating your own LabelFor:
Something like this should do what you need
Update To use the extension method just created in your project, add this line in your
Views\web.config
and then:
or: