HtmlHelperSelectExtensions.DropDownList Method

Definition

Overloads

DropDownList(IHtmlHelper, String)

Returns a single-selection HTML <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".

DropDownList(IHtmlHelper, String, IEnumerable<SelectListItem>)

Returns a single-selection HTML <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".

DropDownList(IHtmlHelper, String, String)

Returns a single-selection HTML <select> element for the expression. Adds <option> elements based on optionLabel and 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".

DropDownList(IHtmlHelper, String, IEnumerable<SelectListItem>, Object)

Returns a single-selection HTML <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".

DropDownList(IHtmlHelper, String, IEnumerable<SelectListItem>, String)

Returns a single-selection HTML <select> element for the expression. Adds <option> elements based on optionLabel and 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".

DropDownList(IHtmlHelper, String)

Source:
HtmlHelperSelectExtensions.cs
Source:
HtmlHelperSelectExtensions.cs

Returns a single-selection HTML <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 ^ DropDownList(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression);
public static Microsoft.AspNetCore.Html.IHtmlContent DropDownList (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression);
static member DropDownList : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function DropDownList (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

DropDownList(IHtmlHelper, String, IEnumerable<SelectListItem>)

Source:
HtmlHelperSelectExtensions.cs
Source:
HtmlHelperSelectExtensions.cs

Returns a single-selection HTML <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 ^ DropDownList(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 DropDownList (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> selectList);
static member DropDownList : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string * seq<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function DropDownList (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.

Applies to

DropDownList(IHtmlHelper, String, String)

Source:
HtmlHelperSelectExtensions.cs
Source:
HtmlHelperSelectExtensions.cs

Returns a single-selection HTML <select> element for the expression. Adds <option> elements based on optionLabel and 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 ^ DropDownList(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression, System::String ^ optionLabel);
public static Microsoft.AspNetCore.Html.IHtmlContent DropDownList (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression, string optionLabel);
static member DropDownList : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string * string -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function DropDownList (htmlHelper As IHtmlHelper, expression As String, optionLabel As String) As IHtmlContent

Parameters

htmlHelper
IHtmlHelper

The IHtmlHelper instance this method extends.

expression
String

Expression name, relative to the current model.

optionLabel
String

The text for a default empty item. Does not include such an item if argument is null.

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

DropDownList(IHtmlHelper, String, IEnumerable<SelectListItem>, Object)

Source:
HtmlHelperSelectExtensions.cs
Source:
HtmlHelperSelectExtensions.cs

Returns a single-selection HTML <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 ^ DropDownList(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression, System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Mvc::Rendering::SelectListItem ^> ^ selectList, System::Object ^ htmlAttributes);
public static Microsoft.AspNetCore.Html.IHtmlContent DropDownList (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> selectList, object htmlAttributes);
static member DropDownList : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string * seq<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> * obj -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function DropDownList (htmlHelper As IHtmlHelper, expression As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As Object) 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.

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.

Remarks

Combines HtmlFieldPrefix and expression to set <select> element's "name" attribute. Sanitizes expression to set element's "id" attribute.

Applies to

DropDownList(IHtmlHelper, String, IEnumerable<SelectListItem>, String)

Source:
HtmlHelperSelectExtensions.cs
Source:
HtmlHelperSelectExtensions.cs

Returns a single-selection HTML <select> element for the expression. Adds <option> elements based on optionLabel and 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 ^ DropDownList(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression, System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Mvc::Rendering::SelectListItem ^> ^ selectList, System::String ^ optionLabel);
public static Microsoft.AspNetCore.Html.IHtmlContent DropDownList (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> selectList, string optionLabel);
static member DropDownList : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string * seq<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> * string -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function DropDownList (htmlHelper As IHtmlHelper, expression As String, selectList As IEnumerable(Of SelectListItem), optionLabel As String) 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.

optionLabel
String

The text for a default empty item. Does not include such an item if argument is null.

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.

Applies to