views:

63

answers:

1

Hi,

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 })%>
A: 

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
specifying size changes the select to be rednered like a listbox. I need the style to remain as a drop down
littlechris
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
"The number of items displayed in the dropdown is a feature of thebrowser and/or operating system. It will vary from user to user and isout of your control."
BuildStarted