【发布时间】:2015-09-23 19:48:40
【问题描述】:
我在 ASP.NET-MVC5 应用程序中有 dropdownListFor,主要是我使用 Bootstrap 样式,但努力做样式 dropdownList。
<div class="form-group">
@Html.LabelFor(model => model.Gender, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.Gender, new SelectListItem[]{
new SelectListItem{Value = "Male", Text="Male"},
new SelectListItem{Value = "Female", Text="Female"}
}, new { htmlAttributes = new { id = "Gender", @class = "form-control" } }
@Html.ValidationMessageFor(model => model.Gender, "", new { @class = "text-danger" })
</div>
</div>
我还有用于整数值的 EditorFor,该字段在 textfild 的最右侧显示小按钮,可用于增加和减少数字,也没有适当的样式,来自 bootstrap
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.StudentNumber_UWLID, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.StudentNumber_UWLID, new { htmlAttributes = new { id = "StudentNumber_UWLID", @class = "form-control" } })
@Html.ValidationMessageFor(model => model.StudentNumber_UWLID, "", new { @class = "text-danger" })
</div>
</div>
【问题讨论】:
-
您希望将哪种样式应用于您的下拉菜单和 EditorFor,EditorFor 在 MVC 中有模板,可以用编辑器模板覆盖,或者您可以使用 TextBoxFor 覆盖样式。跨度>
标签: css twitter-bootstrap razor asp.net-mvc-5