【发布时间】:2018-03-20 02:42:39
【问题描述】:
我正在尝试为 asp.net mvc 下拉列表应用 css 类。它适用于案例编辑器,但不适用于案例下拉列表。我的代码中可能缺少哪些部分?
用于下拉菜单的工作 CSS 类
@Html.EditorFor(model => model.role, new { htmlAttributes = new { @class = "form-control" } })
下拉的 CSS 类失败
@Html.DropDownListFor(model => model.role, new SelectList((IEnumerable)ViewData["Roles"], "role1", "role1"), new { htmlAttributes = new { @class = "form-control" } })
【问题讨论】:
-
new { @class = "form-control" }不是new { htmlAttributes = new { @class = "form-control" } } -
DDLF CSS 属性只需使用
new { @class = "form-control" },因为EditorFor没有htmlAttributes但DDLF 有。
标签: css asp.net asp.net-mvc