HtmlHelperSelectExtensions.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(IHtmlHelper, String) |
Returns a multi-selection <select> element for the |
ListBox(IHtmlHelper, String, IEnumerable<SelectListItem>) |
Returns a multi-selection <select> element for the |
ListBox(IHtmlHelper, String)
Returns a multi-selection <select> element for the expression
. Adds
<option> elements based on the ViewData entry with full name. Adds a
"selected" attribute to an <option> if its Value (if non-null
) or
Text matches the first non-null
value found in:
the ModelState entry with full name, or
the expression
evaluated against Model.
See Name(String) for more information about a "full name".
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::AspNetCore::Html::IHtmlContent ^ ListBox(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression);
public static Microsoft.AspNetCore.Html.IHtmlContent ListBox (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression);
static member ListBox : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function ListBox (htmlHelper As IHtmlHelper, expression As String) As IHtmlContent
Parameters
- htmlHelper
- IHtmlHelper
The IHtmlHelper instance this method extends.
- expression
- String
Expression name, relative to the current model.
Returns
A new IHtmlContent containing the <select> element.
Remarks
Combines HtmlFieldPrefix and expression
to set <select> element's "name" attribute. Sanitizes expression
to set element's "id" attribute.
The ViewData entry with full name must be a non-null
collection of SelectListItem objects.
Applies to
ListBox(IHtmlHelper, String, IEnumerable<SelectListItem>)
Returns a multi-selection <select> element for the expression
. Adds
<option> elements based on selectList
. Adds a "selected" attribute to an
<option> if its Value (if non-null
) or
Text matches the first non-null
value found in:
the ModelState entry with full name,
the ViewData entry with full name (unless used instead of
selectList
), or
the expression
evaluated against Model.
See Name(String) for more information about a "full name".
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::AspNetCore::Html::IHtmlContent ^ ListBox(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression, System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Mvc::Rendering::SelectListItem ^> ^ selectList);
public static Microsoft.AspNetCore.Html.IHtmlContent ListBox (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> selectList);
static member ListBox : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string * seq<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function ListBox (htmlHelper As IHtmlHelper, expression As String, selectList As IEnumerable(Of SelectListItem)) As IHtmlContent
Parameters
- htmlHelper
- IHtmlHelper
The IHtmlHelper instance this method extends.
- expression
- String
Expression name, relative to the current model.
- selectList
- IEnumerable<SelectListItem>
A collection of SelectListItem objects used to populate the <select> element with
<optgroup> and <option> elements. If null
, uses the ViewData
entry with full name and that entry must be a collection of SelectListItem objects.
Returns
A new IHtmlContent containing the <select> element.
Remarks
Combines HtmlFieldPrefix and expression
to set <select> element's "name" attribute. Sanitizes expression
to set element's "id" attribute.