Click here to Skip to main content
15,569,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to add this
(data_toggle = "dropdown", aria_haspopup = "true", aria_expanded = "true")
to my mvc dropdownFor list

<div class="btn-group mb-4">
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Action</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>


What I have tried:

This is the code i have added, but not working....

@Html.DropDownListFor(model => model.Gender, new SelectList(ViewBag.dropdown, "value", "Text"),"Select-Gender", new { id = "drop", @class = "form-control col-md-3 btn dropdown-toggle", data_toggle = "dropdown", aria_haspopup = "true", aria_expanded = "true" })
Posted
Updated 2-Feb-21 2:32am
v3

1 solution

DropDownList / DropDownListFor renders a <select> element.

If you want to render a Bootstrap drop-down menu, you need to use a different approach.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900