HtmlHelper.ListBox Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ListBox(String, String, IEnumerable<SelectListItem>) |
Returns an HTML list box control that has the specified name, and that contains the specified list items and default item. |
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean, IDictionary<String,Object>) |
Returns an HTML list box control that has the specified name, size, custom attributes defined by an attribute dictionary, items, default item, and selections, and that specifies whether multiple selections are enabled. |
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean) |
Returns an HTML list box control that has the specified name, size, items, default item, and selections, and that specifies whether multiple selections are enabled. |
ListBox(String, String, IEnumerable<SelectListItem>, Object, Object) |
Returns an HTML list box control that has the specified name, items, default item, and custom attributes defined by an attribute object, and selections. |
ListBox(String, String, IEnumerable<SelectListItem>, Object, IDictionary<String,Object>) |
Returns an HTML list box control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items, default item, and selections. |
ListBox(String, IEnumerable<SelectListItem>, Object, Int32, Boolean) |
Returns an HTML list box control that has the specified name, size, list items, and default selections, and that specifies whether multiple selections are enabled. |
ListBox(String, IEnumerable<SelectListItem>, Object) |
Returns an HTML list box control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items. |
ListBox(String, String, IEnumerable<SelectListItem>, IDictionary<String,Object>) |
Returns an HTML list box control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items and default item. |
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean, Object) |
Returns an HTML list box control that has the specified name, size, custom attributes defined by an attribute object, items, default item, and selections, and that specifies whether multiple selections are enabled. |
ListBox(String, IEnumerable<SelectListItem>, IDictionary<String,Object>) |
Returns an HTML list box control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items. |
ListBox(String, IEnumerable<SelectListItem>) |
Returns an HTML list box control that has the specified name and that contains the specified list items. |
ListBox(String, String, IEnumerable<SelectListItem>, Object) |
Returns an HTML list box control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items and default item. |
ListBox(String, String, IEnumerable<SelectListItem>)
Returns an HTML list box control that has the specified name, and that contains the specified list items and default item.
public System.Web.IHtmlString ListBox(string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem)) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- defaultOption
- String
The text to display for the default option in the list.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list box.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.
Applies to
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean, IDictionary<String,Object>)
Returns an HTML list box control that has the specified name, size, custom attributes defined by an attribute dictionary, items, default item, and selections, and that specifies whether multiple selections are enabled.
public System.Web.IHtmlString ListBox(string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, int size, bool allowMultiple, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * int * bool * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, size As Integer, allowMultiple As Boolean, htmlAttributes As IDictionary(Of String, Object)) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- defaultOption
- String
The text to display for the default option in the list.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list.
- selectedValues
- Object
An object that specifies the items in the list that are selected by default. The selections are retrieved through reflection by examining the properties of the object.
- size
- Int32
The value to assign to the size attribute of the element.
- allowMultiple
- Boolean
true to indicate that multiple selections are enabled; otherwise, false.
- htmlAttributes
- IDictionary<String,Object>
The names and values of custom attributes for the element.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.
Applies to
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean)
Returns an HTML list box control that has the specified name, size, items, default item, and selections, and that specifies whether multiple selections are enabled.
public System.Web.IHtmlString ListBox(string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, int size, bool allowMultiple);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * int * bool -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, size As Integer, allowMultiple As Boolean) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- defaultOption
- String
The text to display for the default option in the list.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list.
- selectedValues
- Object
An object that specifies the items in the list that are selected by default. The selections are retrieved through reflection by examining the properties of the object.
- size
- Int32
The value to assign to the size attribute of the element.
- allowMultiple
- Boolean
true to indicate that multiple selections are enabled; otherwise, false.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.
Applies to
ListBox(String, String, IEnumerable<SelectListItem>, Object, Object)
Returns an HTML list box control that has the specified name, items, default item, and custom attributes defined by an attribute object, and selections.
public System.Web.IHtmlString ListBox(string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, object htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * obj -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, htmlAttributes As Object) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- defaultOption
- String
The text to display for the default option in the list.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list.
- selectedValues
- Object
An object that specifies the items in the list that are selected by default. The selections are retrieved through reflection by examining the properties of the object.
- htmlAttributes
- Object
An object that contains custom attributes for the element. The attribute names and values are retrieved through reflection by examining the properties of the object.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.
Applies to
ListBox(String, String, IEnumerable<SelectListItem>, Object, IDictionary<String,Object>)
Returns an HTML list box control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items, default item, and selections.
public System.Web.IHtmlString ListBox(string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, htmlAttributes As IDictionary(Of String, Object)) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- defaultOption
- String
The text to display for the default option in the list.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list.
- selectedValues
- Object
An object that specifies the items in the list that are selected by default. The selections are retrieved through reflection by examining the properties of the object.
- htmlAttributes
- IDictionary<String,Object>
The names and values of custom attributes for the element.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.
Applies to
ListBox(String, IEnumerable<SelectListItem>, Object, Int32, Boolean)
Returns an HTML list box control that has the specified name, size, list items, and default selections, and that specifies whether multiple selections are enabled.
public System.Web.IHtmlString ListBox(string name, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, int size, bool allowMultiple);
member this.ListBox : string * seq<System.Web.WebPages.Html.SelectListItem> * obj * int * bool -> System.Web.IHtmlString
Public Function ListBox (name As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, size As Integer, allowMultiple As Boolean) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list.
- selectedValues
- Object
An object that specifies the items in the list that are selected by default. The selections are retrieved through reflection by examining the properties of the object.
- size
- Int32
The value to assign to the size attribute of the element.
- allowMultiple
- Boolean
true to indicate that the multiple selections are enabled; otherwise, false.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.
Applies to
ListBox(String, IEnumerable<SelectListItem>, Object)
Returns an HTML list box control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items.
public System.Web.IHtmlString ListBox(string name, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object htmlAttributes);
member this.ListBox : string * seq<System.Web.WebPages.Html.SelectListItem> * obj -> System.Web.IHtmlString
Public Function ListBox (name As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As Object) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list.
- htmlAttributes
- Object
An object that contains custom attributes for the element. The attribute names and values are retrieved through reflection by examining the properties of the object.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.
Applies to
ListBox(String, String, IEnumerable<SelectListItem>, IDictionary<String,Object>)
Returns an HTML list box control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items and default item.
public System.Web.IHtmlString ListBox(string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As IDictionary(Of String, Object)) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- defaultOption
- String
The text to display for the default option in the list.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list.
- htmlAttributes
- IDictionary<String,Object>
The names and values of custom attributes for the element.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.
Applies to
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean, Object)
Returns an HTML list box control that has the specified name, size, custom attributes defined by an attribute object, items, default item, and selections, and that specifies whether multiple selections are enabled.
public System.Web.IHtmlString ListBox(string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, int size, bool allowMultiple, object htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * int * bool * obj -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, size As Integer, allowMultiple As Boolean, htmlAttributes As Object) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- defaultOption
- String
The text to display for the default option in the list.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list.
- selectedValues
- Object
An object that specifies the items in the list that are selected by default. The selections are retrieved through reflection by examining the properties of the object.
- size
- Int32
The value to assign to the size attribute of the element.
- allowMultiple
- Boolean
true to indicate that multiple selections are enabled; otherwise, false.
- htmlAttributes
- Object
An object that contains custom attributes for the element. The attribute names and values are retrieved through reflection by examining the properties of the object.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.
Applies to
ListBox(String, IEnumerable<SelectListItem>, IDictionary<String,Object>)
Returns an HTML list box control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items.
public System.Web.IHtmlString ListBox(string name, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.ListBox : string * seq<System.Web.WebPages.Html.SelectListItem> * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function ListBox (name As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As IDictionary(Of String, Object)) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list.
- htmlAttributes
- IDictionary<String,Object>
The names and values of custom attributes for the element.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.
Applies to
ListBox(String, IEnumerable<SelectListItem>)
Returns an HTML list box control that has the specified name and that contains the specified list items.
public System.Web.IHtmlString ListBox(string name, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList);
member this.ListBox : string * seq<System.Web.WebPages.Html.SelectListItem> -> System.Web.IHtmlString
Public Function ListBox (name As String, selectList As IEnumerable(Of SelectListItem)) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.
Applies to
ListBox(String, String, IEnumerable<SelectListItem>, Object)
Returns an HTML list box control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items and default item.
public System.Web.IHtmlString ListBox(string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As Object) As IHtmlString
Parameters
- name
- String
The value to assign to the name attribute of the HTML select element.
- defaultOption
- String
The text to display for the default option in the list.
- selectList
- IEnumerable<SelectListItem>
A list of SelectListItem instances that are used to populate the list box.
- htmlAttributes
- Object
An object that contains custom attributes for the element. The attribute names and values are retrieved through reflection by examining the properties of the object.
Returns
The HTML markup that represents the list box control.
Exceptions
name
is null or empty.