I have encountered an issue while trying to apply a CSS class to an ASP.NET MVC dropdown list. The CSS class works fine for the EditorFor case, but not for the DropDownListFor case. I am wondering what could be missing from my code?
Here is the working CSS class for dropdown:
@Html.EditorFor(model => model.role, new { htmlAttributes = new { @class = "form-control" } })
And here is the failing CSS class for the dropdown:
@Html.DropDownListFor(model => model.role, new SelectList((IEnumerable)ViewData["Roles"], "role1", "role1"), new { htmlAttributes = new { @class = "form-control" } })