Rappresenta il supporto per effettuare selezioni in un elenco.
System.Web.Mvc.Html.SelectExtensions
Spazio dei nomi: System.Web.Mvc.Html
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
<ExtensionAttribute> _ Public NotInheritable Class SelectExtensions
Non è necessario dichiarare un'istanza di una classe statica per accedere ai relativi membri.
public static class SelectExtensions
[ExtensionAttribute] public ref class SelectExtensions abstract sealed
public final class SelectExtensions
| Nome | Descrizione | |
|---|---|---|
|
DropDownList(HtmlHelper, String) | Restituisce un elemento select a selezione singola utilizzando l'helper HTML e il nome del campo del form specificati. |
|
DropDownList(HtmlHelper, String, IEnumerable<SelectListItem>) | Restituisce un elemento select a selezione singola utilizzando l'helper HTML, il nome del campo del form e gli elementi dell'elenco specificati. |
|
DropDownList(HtmlHelper, String, String) | Restituisce un elemento select a selezione singola utilizzando l'helper HTML, il nome del campo del form e un'etichetta di opzione specificati. |
|
DropDownList(HtmlHelper, String, IEnumerable<SelectListItem>, IDictionary<String, Object>) | Restituisce un elemento select a selezione singola utilizzando l'helper HTML, il nome del campo del form, gli elementi dell'elenco e gli attributi HTML specificati. |
|
DropDownList(HtmlHelper, String, IEnumerable<SelectListItem>, Object) | Restituisce un elemento select a selezione singola utilizzando l'helper HTML, il nome del campo del form, gli elementi dell'elenco e gli attributi HTML specificati. |
|
DropDownList(HtmlHelper, String, IEnumerable<SelectListItem>, String) | Restituisce un elemento select a selezione singola utilizzando l'helper HTML, il nome del campo del form, gli elementi dell'elenco e un'etichetta di opzione specificati. |
|
DropDownList(HtmlHelper, String, IEnumerable<SelectListItem>, String, IDictionary<String, Object>) | Restituisce un elemento select a selezione singola utilizzando l'helper HTML, il nome del campo del form, gli elementi dell'elenco, un'etichetta di opzione e gli attributi HTML specificati. |
|
DropDownList(HtmlHelper, String, IEnumerable<SelectListItem>, String, Object) | Restituisce un elemento select a selezione singola utilizzando l'helper HTML, il nome del campo del form, gli elementi dell'elenco, un'etichetta di opzione e gli attributi HTML specificati. |
|
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>) | Restituisce un elemento HTML select per ogni proprietà nell'oggetto rappresentato dall'espressione specificata, utilizzando gli elementi dell'elenco specificati. |
|
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, IDictionary<String, Object>) | Restituisce un elemento HTML select per ogni proprietà nell'oggetto rappresentato dall'espressione specificata, utilizzando gli elementi dell'elenco e gli attributi HTML specificati. |
|
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, Object) | Restituisce un elemento HTML select per ogni proprietà nell'oggetto rappresentato dall'espressione specificata, utilizzando gli elementi dell'elenco e gli attributi HTML specificati. |
|
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, String) | Restituisce un elemento HTML select per ogni proprietà nell'oggetto rappresentato dall'espressione specificata, utilizzando gli elementi dell'elenco e l'etichetta di opzione specificati. |
|
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, String, IDictionary<String, Object>) | Restituisce un elemento HTML select per ogni proprietà nell'oggetto rappresentato dall'espressione specificata, utilizzando gli elementi dell'elenco, l'etichetta di opzione e gli attributi HTML specificati. |
|
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, String, Object) | Restituisce un elemento HTML select per ogni proprietà nell'oggetto rappresentato dall'espressione specificata, utilizzando gli elementi dell'elenco, l'etichetta di opzione e gli attributi HTML specificati. |
|
ListBox(HtmlHelper, String) | Restituisce un elemento select a selezione multipla utilizzando l'helper HTML e il nome del campo del form specificati. |
|
ListBox(HtmlHelper, String, IEnumerable<SelectListItem>) | Restituisce un elemento select a selezione multipla utilizzando l'helper HTML, il nome del campo del form e gli elementi dell'elenco specificati. |
|
ListBox(HtmlHelper, String, IEnumerable<SelectListItem>, IDictionary<String, Object>) | Restituisce un elemento select a selezione multipla utilizzando l'helper HTML, il nome del campo del form, gli elementi dell'elenco e gli attributi HTML specificati. |
|
ListBox(HtmlHelper, String, IEnumerable<SelectListItem>, Object) | Restituisce un elemento select a selezione multipla utilizzando l'helper HTML, il nome del campo del form e gli elementi dell'elenco specificati. |
|
ListBoxFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>) | Restituisce un elemento select HTML per ogni proprietà nell'oggetto rappresentato dall'espressione specificata e utilizzando gli elementi dell'elenco specificati. |
|
ListBoxFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, IDictionary<String, Object>) | Restituisce un elemento HTML select per ogni proprietà nell'oggetto rappresentato dall'espressione specificata, utilizzando gli elementi dell'elenco e gli attributi HTML specificati. |
|
ListBoxFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, Object) | Restituisce un elemento HTML select per ogni proprietà nell'oggetto rappresentato dall'espressione specificata, utilizzando gli elementi dell'elenco e gli attributi HTML specificati. |
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.
In the following example, the list of items for each control is created in the Index action method and passed to the view in the ViewDataDictionary object.
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.
When the user submits the form, the Selection action method handles the request and renders the view that displays the selections.
The following view displays the user selections.