I am trying to apply css class for asp.net mvc dropdown list. It works for editorfor case but not for dropdownlistfor case. What may be the missing part from my code?
Working css class for dropdown
@Html.EditorFor(model => model.role, new { htmlAttributes = new { @class = "form-control" } })
failing css class for drowdown
@Html.DropDownListFor(model => model.role, new SelectList((IEnumerable)ViewData["Roles"], "role1", "role1"), new { htmlAttributes = new { @class = "form-control" } })
new { @class = "form-control" }notnew { htmlAttributes = new { @class = "form-control" } }new { @class = "form-control" }for DDLF CSS attribute, becauseEditorFordoesn't havehtmlAttributesbut DDLF has it.