Given is the following MVC razor code which creates a dropdown from a list:
@Html.DropDownList("MyTestList", null, new { @class = "btn btn-default dropdown-toggle" })
This will create the following dropdown:
When using the code from getbootstrap.com:
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">test1</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">test2</a></li>
</ul>
</div>
It will show the dropdown like this:
Question:
Is it possible to get the same look and feel when using @Html.DropDownList
as when using the HTML code from MVC?
question from:
https://stackoverflow.com/questions/26555493/how-to-apply-bootstrap-dropdown-style-to-an-asp-net-mvc-dropdownlist 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…