The
htmlAttributes
part is only required if you're using
EditorFor
. With
DropDownListFor
, or
TextBoxFor
, or any of the other helpers which render a single control, the object contains the attributes directly:
@Html.DropDownListFor(model => model.MyList,
new SelectList(...), " - Select or Add -",
new { @class = "form-control" })
Html.EditorFor and htmlAttributes[
^]