Without modifying my Editor Templates, is it possible to pass other HTML attributes into the Html.EditorFor
Helper extension?
The example shows a class being passed in:
@Html.EditorFor(model => model.information, new { htmlAttributes = new { @class = "form-control" }})
There are many potential scenarios but I want to decorate my input with a data-myvar="value"
. When I try this I get compiler errors invalid anonymous type declaratory
.
@Html.EditorFor(model => model.information, new { htmlAttributes = new { @data-myvar="value" }})
Additionally if it is possible can I pass this in in addition to a class? i.e. pass in an array of htmlattributes
. I'm struggling to find any documentation apart from the release notes.