How to apply Bootstrap dropdown style to an ASP.NET MVC DropDownList?

前端 未结 6 1186
孤街浪徒
孤街浪徒 2021-01-30 08:47

Given is the following MVC razor code which creates a dropdown from a list:

@Html.DropDownList(\"MyTestList\", null, new { @class = \"btn btn-default dropdown-t         


        
6条回答
  •  臣服心动
    2021-01-30 09:29

    @using (Html.BeginForm("Index", "ELibrary"))
    {
    @Html.DropDownListFor(m => m.Status, new SelectList(Model.StatusItems, "key", "value"), "-- Status --", new { onchange = "this.form.submit();", @class = "form-control" })
    }
    

    You just have to add @class="form-control" . It works fine. but I have also enclosed it in a Html.Begin form();

提交回复
热议问题