Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
790 views
in Technique[技术] by (71.8m points)

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

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:

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:

image

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...