HtmlHelperSelectExtensions Class¶
Summary¶
Select-related extensions for [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) and [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1.yml).
Methods¶
-
DropDownList
(Microsoft.AspNet.Mvc.Rendering.IHtmlHelper, System.String)¶ Returns a single-selection HTML <select> element for the <paramref name=”expression” />.
Arguments: - htmlHelper (Microsoft.AspNet.Mvc.Rendering.IHtmlHelper) – The [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) instance this method extends.
- expression (System.String) – Expression name, relative to the current model.
Return type: Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns: A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the <select> element.
public static HtmlString DropDownList(IHtmlHelper htmlHelper, string expression)
-
DropDownList
(Microsoft.AspNet.Mvc.Rendering.IHtmlHelper, System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>) Returns a single-selection HTML <select> element for the <paramref name=”expression” />, using the specified list items.
Arguments: - htmlHelper (Microsoft.AspNet.Mvc.Rendering.IHtmlHelper) – The [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) instance this method extends.
- expression (System.String) – Expression name, relative to the current model.
- selectList (System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) objects used to populate the <select> element with <optgroup> and <option> elements.
Return type: Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns: A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the <select> element.
public static HtmlString DropDownList(IHtmlHelper htmlHelper, string expression, IEnumerable<SelectListItem> selectList)
-
DropDownList
(Microsoft.AspNet.Mvc.Rendering.IHtmlHelper, System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>, System.Object) Returns a single-selection HTML <select> element for the <paramref name=”expression” />, using the specified list items and HTML attributes.
Arguments: - htmlHelper (Microsoft.AspNet.Mvc.Rendering.IHtmlHelper) – The [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) instance this method extends.
- expression (System.String) – Expression name, relative to the current model.
- selectList (System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) 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, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type: Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns: A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the <select> element.
public static HtmlString DropDownList(IHtmlHelper htmlHelper, string expression, IEnumerable<SelectListItem> selectList, object htmlAttributes)
-
DropDownList
(Microsoft.AspNet.Mvc.Rendering.IHtmlHelper, System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>, System.String) Returns a single-selection HTML <select> element for the <paramref name=”expression” />, using the specified list items and option label.
Arguments: - htmlHelper (Microsoft.AspNet.Mvc.Rendering.IHtmlHelper) – The [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) instance this method extends.
- expression (System.String) – Expression name, relative to the current model.
- selectList (System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) 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 <c>null</c>.
Return type: Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns: A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the <select> element.
public static HtmlString DropDownList(IHtmlHelper htmlHelper, string expression, IEnumerable<SelectListItem> selectList, string optionLabel)
-
DropDownList
(Microsoft.AspNet.Mvc.Rendering.IHtmlHelper, System.String, System.String) Returns a single-selection HTML <select> element for the <paramref name=”expression” />, using the option label.
Arguments: - htmlHelper (Microsoft.AspNet.Mvc.Rendering.IHtmlHelper) – The [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) 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 <c>null</c>.
Return type: Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns: A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the <select> element.
public static HtmlString DropDownList(IHtmlHelper htmlHelper, string expression, string optionLabel)
-
Microsoft.AspNet.Mvc.Rendering.HtmlHelperSelectExtensions.DropDownListFor<TModel, TResult>(Microsoft.AspNet.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>)
Returns a single-selection HTML <select> element for the <paramref name=”expression” />, using the specified list items.
Arguments: - htmlHelper (Microsoft.AspNet.Mvc.Rendering.IHtmlHelper{{TModel}}) – The [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1.yml) 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.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) objects used to populate the <select> element with <optgroup> and <option> elements.
Return type: Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns: A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the <select> element.
public static HtmlString DropDownListFor<TModel, TResult>(IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, IEnumerable<SelectListItem> selectList)
-
Microsoft.AspNet.Mvc.Rendering.HtmlHelperSelectExtensions.DropDownListFor<TModel, TResult>(Microsoft.AspNet.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>, System.Object)
Returns a single-selection HTML <select> element for the <paramref name=”expression” />, using the specified list items and HTML attributes.
Arguments: - htmlHelper (Microsoft.AspNet.Mvc.Rendering.IHtmlHelper{{TModel}}) – The [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1.yml) 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.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) 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, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type: Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns: A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the <select> element.
public static HtmlString DropDownListFor<TModel, TResult>(IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, IEnumerable<SelectListItem> selectList, object htmlAttributes)
-
Microsoft.AspNet.Mvc.Rendering.HtmlHelperSelectExtensions.DropDownListFor<TModel, TResult>(Microsoft.AspNet.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>, System.String)
Returns a single-selection HTML <select> element for the <paramref name=”expression” />, using the specified list items and option label.
Arguments: - htmlHelper (Microsoft.AspNet.Mvc.Rendering.IHtmlHelper{{TModel}}) – The [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1.yml) 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.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) 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 <c>null</c>.
Return type: Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns: A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the <select> element.
public static HtmlString DropDownListFor<TModel, TResult>(IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, IEnumerable<SelectListItem> selectList, string optionLabel)
-
ListBox
(Microsoft.AspNet.Mvc.Rendering.IHtmlHelper, System.String)¶ Returns a multi-selection <select> element for the <paramref name=”expression” />.
Arguments: - htmlHelper (Microsoft.AspNet.Mvc.Rendering.IHtmlHelper) – The [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) instance this method extends.
- expression (System.String) – Expression name, relative to the current model.
Return type: Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns: A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the <select> element.
public static HtmlString ListBox(IHtmlHelper htmlHelper, string expression)
-
ListBox
(Microsoft.AspNet.Mvc.Rendering.IHtmlHelper, System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>) Returns a multi-selection <select> element for the <paramref name=”expression” />, using the specified list items.
Arguments: - htmlHelper (Microsoft.AspNet.Mvc.Rendering.IHtmlHelper) – The [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) instance this method extends.
- expression (System.String) – Expression name, relative to the current model.
- selectList (System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) objects used to populate the <select> element with <optgroup> and <option> elements.
Return type: Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns: A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the <select> element.
public static HtmlString ListBox(IHtmlHelper htmlHelper, string expression, IEnumerable<SelectListItem> selectList)
-
Microsoft.AspNet.Mvc.Rendering.HtmlHelperSelectExtensions.ListBoxFor<TModel, TResult>(Microsoft.AspNet.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>)
Returns a multi-selection <select> element for the <paramref name=”expression” />, using the specified list items.
Arguments: - htmlHelper (Microsoft.AspNet.Mvc.Rendering.IHtmlHelper{{TModel}}) – The [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1.yml) 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.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) objects used to populate the <select> element with <optgroup> and <option> elements.
Return type: Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns: A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the <select> element.
public static HtmlString ListBoxFor<TModel, TResult>(IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, IEnumerable<SelectListItem> selectList)
-