@Html.DropDownList Always opened showing the first 5 items and possibility to scroll down (no multiple choice) RRS feed

  • Question

  • User1991482975 posted


    i have a classi dropdownlist and iwoul love to give  a class called : examplelistfullopened

    @Html.DropDownList("SalonBookingDate", (List<SelectListItem>)ViewBag.DataRange, ViewRes.Shared.Day, htmlAttributes: new { @class = "examplelistfullopened" })

    What i would love to achiver is the following, in stead to have a common dropdownlist (no multiple choice), which i open and i show the list of items, i would love to have a dropdownlist already open and who show always the first 5 items and scroll down to see more..

    is it possible to achive this with only css? or other solutions?


    Monday, November 21, 2016 4:42 PM

All replies

  • User-654786183 posted

    you can set the size property for the dropdown

    @Html.DropDownList("SalonBookingDate", (List<SelectListItem>)ViewBag.DataRange, ViewRes.Shared.Day, htmlAttributes: new { @class = "examplelistfullopened", size=5 })

    Please refer this link

    Monday, November 21, 2016 4:52 PM
  • User1991482975 posted

    Ok, like this it is already opened at the beginnig right?

    Adn if i would love to first click and after open a fixed list? how to do?

    Monday, November 21, 2016 4:55 PM
  • User753101303 posted


    Yes. You could then add dynamically the size on the first click but IMHO it would be suprising for users to see a drop down being turned into a list box. I would likely just show it opened from the very beginning if this is anyway how you want to show it once clicked at least one time...

    Or change this dynamically and see if it seems right from a UI perspective.

    Monday, November 21, 2016 5:07 PM