我需要向 DropDownList 添加一个类,使其看起来更美观。因此,我使用下面的代码htmlAttribute
:
@Html.DropDownList("DepartmentId", "Select a Department:", htmlAttributes: new { @class = "form-control" })
我收到错误,因为它说:
does not contain a definition for 'DropDownList' and the best extension method overload 'System.Web.Mvc.Html.SelectExtensions.DropDownList(System.Web.Mvc.HtmlHelper, string, System.Collections.Generic.IEnumerable<System.Web.Mvc.SelectListItem>, string)' has some invalid arguments
有人可以教我如何添加表单控件类来做 DropDownList 吗?
正在运行的代码:
@Html.DropDownList("DepartmentId", null, htmlAttributes: new { @class = "form-control" })