2

I have a drop down list of around 30 items and I want to only show 8 items and then the drop down should scroll. I'm using MVC2 in VS2010

<%= Html.DropDownListFor(d => d.Thing.ThingID, Model.Things, new { style = "width: 200px", rows = 10 })%>
littlechris
  • 4,174
  • 10
  • 43
  • 66

1 Answers1

0

have you tried size instead of rows?

<%= Html.DropDownListFor(d => d.Thing.ThingID, Model.Things, new { style = "width: 200px", size = 10 })%>

According to the w3 http://www.w3schools.com/tags/att_select_size.asp size is the attribute you're looking for.

After reading your response the answer appears to be that it's operating system/browser independent and not possible to control through html. What you could do is override the select box with an HTML only version. You could do something like on this site: http://mypocket-technologies.com/jquery/SelectBoxPlugin/ However it may cause other problems and won't look like a standard list box.

Buildstarted
  • 26,529
  • 10
  • 84
  • 95
  • specifying size changes the select to be rednered like a listbox. I need the style to remain as a drop down – littlechris Sep 20 '10 at 14:44
  • Ah, it's probably a browser thing to render in different sizes depending on content and available screen real estate. Looking around there's no defined standard for doing what you want. – Buildstarted Sep 20 '10 at 14:49
  • 2
    "The number of items displayed in the dropdown is a feature of the browser and/or operating system. It will vary from user to user and is out of your control." – Buildstarted Sep 20 '10 at 14:55