The SelectExtensions class contains methods that extend the HtmlHelper class. Each extension method renders an HTML select element. The DropDownList method renders an element that enables the user to select an item from a drop-down list. The ListBox method renders an element that enables the user to select from a scrolling list of items.

The following example shows how to use both the DropDownList and ListBox methods in a view. The ListBox control displays a list of book titles, from which the user can select one or more books. The DropDownList displays a list of pets, from which the user can select one pet. The selections are then displayed in another view.

The following classes define the data model that is used for a book and a pet.

The following example shows a view that displays the entry form that contains the list box and the drop-down list. The list box is passed an anonymous object that defines the HMTL size attribute for the rendered list box.