HtmlHelperSelectExtensions Class¶
Select-related extensions for Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper
and Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper`1
.
- Namespace
Microsoft.AspNetCore.Mvc.Rendering
- Assemblies
- Microsoft.AspNetCore.Mvc.ViewFeatures
Syntax¶
public class HtmlHelperSelectExtensions
-
class
Microsoft.AspNetCore.Mvc.Rendering.
HtmlHelperSelectExtensions
Methods¶
-
DropDownList
(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String)¶ Returns a single-selection HTML <select> element for the <em>expression</em>.
Arguments: - htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper
instance this method extends. - expression (System.String) – Expression name, relative to the current model.
Return type: Returns: A new
Microsoft.AspNetCore.Html.IHtmlContent
containing the <select> element.public static IHtmlContent DropDownList(this IHtmlHelper htmlHelper, string expression)
- htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
-
DropDownList
(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>) Returns a single-selection HTML <select> element for the <em>expression</em>, using the specified list items.
Arguments: - htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper
instance this method extends. - expression (System.String) – Expression name, relative to the current model.
- selectList (System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>) – A collection of
Microsoft.AspNetCore.Mvc.Rendering.SelectListItem
objects used to populate the <select> element with <optgroup> and <option> elements.
Return type: Returns: A new
Microsoft.AspNetCore.Html.IHtmlContent
containing the <select> element.public static IHtmlContent DropDownList(this IHtmlHelper htmlHelper, string expression, IEnumerable<SelectListItem> selectList)
- htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
-
DropDownList
(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>, System.Object) Returns a single-selection HTML <select> element for the <em>expression</em>, using the specified list items and HTML attributes.
Arguments: - htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper
instance this method extends. - expression (System.String) – Expression name, relative to the current model.
- selectList (System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>) – A collection of
Microsoft.AspNetCore.Mvc.Rendering.SelectListItem
objects used to populate the <select> element with <optgroup> and <option> elements. - htmlAttributes (System.Object) – An
System.Object
that contains the HTML attributes for the <select> element. Alternatively, anSystem.Collections.Generic.IDictionary`2
instance containing the HTML attributes.
Return type: Returns: A new
Microsoft.AspNetCore.Html.IHtmlContent
containing the <select> element.public static IHtmlContent DropDownList(this IHtmlHelper htmlHelper, string expression, IEnumerable<SelectListItem> selectList, object htmlAttributes)
- htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
-
DropDownList
(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>, System.String) Returns a single-selection HTML <select> element for the <em>expression</em>, using the specified list items and option label.
Arguments: - htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper
instance this method extends. - expression (System.String) – Expression name, relative to the current model.
- selectList (System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>) – A collection of
Microsoft.AspNetCore.Mvc.Rendering.SelectListItem
objects used to populate the <select> element with <optgroup> and <option> elements. - optionLabel (System.String) – The text for a default empty item. Does not include such an item if argument is <code>null</code>.
Return type: Returns: A new
Microsoft.AspNetCore.Html.IHtmlContent
containing the <select> element.public static IHtmlContent DropDownList(this IHtmlHelper htmlHelper, string expression, IEnumerable<SelectListItem> selectList, string optionLabel)
- htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
-
DropDownList
(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String) Returns a single-selection HTML <select> element for the <em>expression</em>, using the option label.
Arguments: - htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper
instance this method extends. - expression (System.String) – Expression name, relative to the current model.
- optionLabel (System.String) – The text for a default empty item. Does not include such an item if argument is <code>null</code>.
Return type: Returns: A new
Microsoft.AspNetCore.Html.IHtmlContent
containing the <select> element.public static IHtmlContent DropDownList(this IHtmlHelper htmlHelper, string expression, string optionLabel)
- htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
-
DropDownListFor<TModel, TResult>
(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)¶ Returns a single-selection HTML <select> element for the <em>expression</em>, using the specified list items.
Arguments: - htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>) – The
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper`1
instance this method extends. - expression (System.Linq.Expressions.Expression<System.Func<TModel, TResult>>) – An expression to be evaluated against the current model.
- selectList (System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>) – A collection of
Microsoft.AspNetCore.Mvc.Rendering.SelectListItem
objects used to populate the <select> element with <optgroup> and <option> elements.
Return type: Returns: A new
Microsoft.AspNetCore.Html.IHtmlContent
containing the <select> element.public static IHtmlContent DropDownListFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, IEnumerable<SelectListItem> selectList)
- htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>) – The
-
DropDownListFor<TModel, TResult>
(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>, System.Object) Returns a single-selection HTML <select> element for the <em>expression</em>, using the specified list items and HTML attributes.
Arguments: - htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>) – The
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper`1
instance this method extends. - expression (System.Linq.Expressions.Expression<System.Func<TModel, TResult>>) – An expression to be evaluated against the current model.
- selectList (System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>) – A collection of
Microsoft.AspNetCore.Mvc.Rendering.SelectListItem
objects used to populate the <select> element with <optgroup> and <option> elements. - htmlAttributes (System.Object) – An
System.Object
that contains the HTML attributes for the <select> element. Alternatively, anSystem.Collections.Generic.IDictionary`2
instance containing the HTML attributes.
Return type: Returns: A new
Microsoft.AspNetCore.Html.IHtmlContent
containing the <select> element.public static IHtmlContent DropDownListFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, IEnumerable<SelectListItem> selectList, object htmlAttributes)
- htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>) – The
-
DropDownListFor<TModel, TResult>
(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>, System.String) Returns a single-selection HTML <select> element for the <em>expression</em>, using the specified list items and option label.
Arguments: - htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>) – The
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper`1
instance this method extends. - expression (System.Linq.Expressions.Expression<System.Func<TModel, TResult>>) – An expression to be evaluated against the current model.
- selectList (System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>) – A collection of
Microsoft.AspNetCore.Mvc.Rendering.SelectListItem
objects used to populate the <select> element with <optgroup> and <option> elements. - optionLabel (System.String) – The text for a default empty item. Does not include such an item if argument is <code>null</code>.
Return type: Returns: A new
Microsoft.AspNetCore.Html.IHtmlContent
containing the <select> element.public static IHtmlContent DropDownListFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, IEnumerable<SelectListItem> selectList, string optionLabel)
- htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>) – The
-
ListBox
(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String)¶ Returns a multi-selection <select> element for the <em>expression</em>.
Arguments: - htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper
instance this method extends. - expression (System.String) – Expression name, relative to the current model.
Return type: Returns: A new
Microsoft.AspNetCore.Html.IHtmlContent
containing the <select> element.public static IHtmlContent ListBox(this IHtmlHelper htmlHelper, string expression)
- htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
-
ListBox
(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>) Returns a multi-selection <select> element for the <em>expression</em>, using the specified list items.
Arguments: - htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper
instance this method extends. - expression (System.String) – Expression name, relative to the current model.
- selectList (System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>) – A collection of
Microsoft.AspNetCore.Mvc.Rendering.SelectListItem
objects used to populate the <select> element with <optgroup> and <option> elements.
Return type: Returns: A new
Microsoft.AspNetCore.Html.IHtmlContent
containing the <select> element.public static IHtmlContent ListBox(this IHtmlHelper htmlHelper, string expression, IEnumerable<SelectListItem> selectList)
- htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The
-
ListBoxFor<TModel, TResult>
(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)¶ Returns a multi-selection <select> element for the <em>expression</em>, using the specified list items.
Arguments: - htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>) – The
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper`1
instance this method extends. - expression (System.Linq.Expressions.Expression<System.Func<TModel, TResult>>) – An expression to be evaluated against the current model.
- selectList (System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>) – A collection of
Microsoft.AspNetCore.Mvc.Rendering.SelectListItem
objects used to populate the <select> element with <optgroup> and <option> elements.
Return type: Returns: A new
Microsoft.AspNetCore.Html.IHtmlContent
containing the <select> element.public static IHtmlContent ListBoxFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, IEnumerable<SelectListItem> selectList)
- htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>) – The
-