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

前端 未结 6 1184
孤街浪徒
孤街浪徒 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:36

    It is very much possible, and really easy. Please Read: DropDownList bootstrap styling

    All you need is:

    @Html.DropDownList("movieGenre", "All", new { @class = "form-control"})
    

    or

    @Html.DropDownListFor(model => model.MovieGenreModel, SelectList, new { @class = "form-control"})
    

提交回复
热议问题