Dela via


HtmlHelper.ListBox(String, IEnumerable<SelectListItem>, Object) Method

Definition

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 an entry in the first non-null collection 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:
 virtual Microsoft::AspNetCore::Html::IHtmlContent ^ ListBox(System::String ^ expression, System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Mvc::Rendering::SelectListItem ^> ^ selectList, System::Object ^ htmlAttributes);
public Microsoft.AspNetCore.Html.IHtmlContent ListBox (string expression, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> selectList, object htmlAttributes);
abstract member ListBox : string * seq<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> * obj -> Microsoft.AspNetCore.Html.IHtmlContent
override this.ListBox : string * seq<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> * obj -> Microsoft.AspNetCore.Html.IHtmlContent
Public Function ListBox (expression As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As Object) As IHtmlContent

Parameters

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, finds the SelectListItem collection with name expression in ViewData.

htmlAttributes
Object

An Object that contains the HTML attributes for the <select> element. Alternatively, an IDictionary<TKey,TValue> instance containing the HTML attributes.

Returns

A new IHtmlContent containing the <select> element.

Implements

Applies to