Class SelectExtensions
Represents support for making selections in a list.
public static class SelectExtensions
- Inheritance
-
SelectExtensions
- Inherited Members
Methods
DropDownList(HtmlHelper, string)
Returns a single-selection select element using the specified HTML helper and the name of the form field.
public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
Returns
- MvcHtmlString
An HTML select element.
Exceptions
- ArgumentException
The
nameparameter is null or empty.
DropDownList(HtmlHelper, string, IEnumerable<SelectListItem>)
Returns a single-selection select element using the specified HTML helper, the name of the form field, and the specified list items.
public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
Returns
- MvcHtmlString
An HTML select element with an option subelement for each item in the list.
Exceptions
- ArgumentException
The
nameparameter is null or empty.
DropDownList(HtmlHelper, string, IEnumerable<SelectListItem>, IDictionary<string, object>)
Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, and the specified HTML attributes.
public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributesIDictionary<string, object>An object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element with an option subelement for each item in the list.
Exceptions
- ArgumentException
The
nameparameter is null or empty.
DropDownList(HtmlHelper, string, IEnumerable<SelectListItem>, object)
Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, and the specified HTML attributes.
public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, object htmlAttributes)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributesobjectAn object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element with an option subelement for each item in the list.
Exceptions
- ArgumentException
The
nameparameter is null or empty.
DropDownList(HtmlHelper, string, IEnumerable<SelectListItem>, string)
Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, and an option label.
public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, string optionLabel)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabelstringThe text for a default empty item. This parameter can be null.
Returns
- MvcHtmlString
An HTML select element with an option subelement for each item in the list.
Exceptions
- ArgumentException
The
nameparameter is null or empty.
DropDownList(HtmlHelper, string, IEnumerable<SelectListItem>, string, IDictionary<string, object>)
Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, an option label, and the specified HTML attributes.
public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, string optionLabel, IDictionary<string, object> htmlAttributes)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabelstringThe text for a default empty item. This parameter can be null.
htmlAttributesIDictionary<string, object>An object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element with an option subelement for each item in the list.
Exceptions
- ArgumentException
The
nameparameter is null or empty.
DropDownList(HtmlHelper, string, IEnumerable<SelectListItem>, string, object)
Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, an option label, and the specified HTML attributes.
public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, string optionLabel, object htmlAttributes)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabelstringThe text for a default empty item. This parameter can be null.
htmlAttributesobjectAn object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element with an option subelement for each item in the list.
Exceptions
- ArgumentException
The
nameparameter is null or empty.
DropDownList(HtmlHelper, string, string)
Returns a single-selection select element using the specified HTML helper, the name of the form field, and an option label.
public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, string optionLabel)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
optionLabelstringThe text for a default empty item. This parameter can be null.
Returns
- MvcHtmlString
An HTML select element with an option subelement for each item in the list.
Exceptions
- ArgumentException
The
nameparameter is null or empty.
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>)
Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items.
public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
Returns
- MvcHtmlString
An HTML select element for each property in the object that is represented by the expression.
Type Parameters
TModelThe type of the model.
TPropertyThe type of the value.
Exceptions
- ArgumentNullException
The
expressionparameter is null.
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, IDictionary<string, object>)
Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items and HTML attributes.
public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributesIDictionary<string, object>An object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element for each property in the object that is represented by the expression.
Type Parameters
TModelThe type of the model.
TPropertyThe type of the value.
Exceptions
- ArgumentNullException
The
expressionparameter is null.
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, object)
Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items and HTML attributes.
public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, object htmlAttributes)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributesobjectAn object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element for each property in the object that is represented by the expression.
Type Parameters
TModelThe type of the model.
TPropertyThe type of the value.
Exceptions
- ArgumentNullException
The
expressionparameter is null.
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, string)
Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items and option label.
public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabelstringThe text for a default empty item. This parameter can be null.
Returns
- MvcHtmlString
An HTML select element for each property in the object that is represented by the expression.
Type Parameters
TModelThe type of the model.
TPropertyThe type of the value.
Exceptions
- ArgumentNullException
The
expressionparameter is null.
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, string, IDictionary<string, object>)
Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items, option label, and HTML attributes.
public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel, IDictionary<string, object> htmlAttributes)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabelstringThe text for a default empty item. This parameter can be null.
htmlAttributesIDictionary<string, object>An object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element for each property in the object that is represented by the expression.
Type Parameters
TModelThe type of the model.
TPropertyThe type of the value.
Exceptions
- ArgumentNullException
The
expressionparameter is null.
DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, string, object)
Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items, option label, and HTML attributes.
public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel, object htmlAttributes)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabelstringThe text for a default empty item. This parameter can be null.
htmlAttributesobjectAn object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element for each property in the object that is represented by the expression.
Type Parameters
TModelThe type of the model.
TPropertyThe type of the value.
Exceptions
- ArgumentNullException
The
expressionparameter is null.
EnumDropDownListFor<TModel, TEnum>(HtmlHelper<TModel>, Expression<Func<TModel, TEnum>>)
Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TEnum>> expression)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TEnum>>An expression that identifies the object that contains the values to display.
Returns
- MvcHtmlString
An HTML select element for each value in the enumeration that is represented by the expression.
Type Parameters
TModelThe type of the model.
TEnumThe type of the value.
EnumDropDownListFor<TModel, TEnum>(HtmlHelper<TModel>, Expression<Func<TModel, TEnum>>, IDictionary<string, object>)
Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TEnum>> expression, IDictionary<string, object> htmlAttributes)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TEnum>>An expression that identifies the object that contains the values to display.
htmlAttributesIDictionary<string, object>An object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element for each value in the enumeration that is represented by the expression.
Type Parameters
TModelThe type of the model.
TEnumThe type of the value.
EnumDropDownListFor<TModel, TEnum>(HtmlHelper<TModel>, Expression<Func<TModel, TEnum>>, object)
Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TEnum>> expression, object htmlAttributes)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TEnum>>An expression that identifies the object that contains the values to display.
htmlAttributesobjectAn object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element for each value in the enumeration that is represented by the expression.
Type Parameters
TModelThe type of the model.
TEnumThe type of the value.
EnumDropDownListFor<TModel, TEnum>(HtmlHelper<TModel>, Expression<Func<TModel, TEnum>>, string)
Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TEnum>> expression, string optionLabel)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TEnum>>An expression that identifies the object that contains the values to display.
optionLabelstringThe text for a default empty item. This parameter can be null.
Returns
- MvcHtmlString
An HTML select element for each value in the enumeration that is represented by the expression.
Type Parameters
TModelThe type of the model.
TEnumThe type of the value.
EnumDropDownListFor<TModel, TEnum>(HtmlHelper<TModel>, Expression<Func<TModel, TEnum>>, string, IDictionary<string, object>)
Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TEnum>> expression, string optionLabel, IDictionary<string, object> htmlAttributes)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TEnum>>An expression that identifies the object that contains the values to display.
optionLabelstringThe text for a default empty item. This parameter can be null.
htmlAttributesIDictionary<string, object>An object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element for each value in the enumeration that is represented by the expression.
Type Parameters
TModelThe type of the model.
TEnumThe type of the value.
EnumDropDownListFor<TModel, TEnum>(HtmlHelper<TModel>, Expression<Func<TModel, TEnum>>, string, object)
Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TEnum>> expression, string optionLabel, object htmlAttributes)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TEnum>>An expression that identifies the object that contains the values to display.
optionLabelstringThe text for a default empty item. This parameter can be null.
htmlAttributesobjectAn object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element for each value in the enumeration that is represented by the expression.
Type Parameters
TModelThe type of the model.
TEnumThe type of the value.
ListBox(HtmlHelper, string)
Returns a multi-select select element using the specified HTML helper and the name of the form field.
public static MvcHtmlString ListBox(this HtmlHelper htmlHelper, string name)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
Returns
- MvcHtmlString
An HTML select element.
Exceptions
- ArgumentException
The
nameparameter is null or empty.
ListBox(HtmlHelper, string, IEnumerable<SelectListItem>)
Returns a multi-select select element using the specified HTML helper, the name of the form field, and the specified list items.
public static MvcHtmlString ListBox(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
Returns
- MvcHtmlString
An HTML select element with an option subelement for each item in the list.
Exceptions
- ArgumentException
The
nameparameter is null or empty.
ListBox(HtmlHelper, string, IEnumerable<SelectListItem>, IDictionary<string, object>)
Returns a multi-select select element using the specified HTML helper, the name of the form field, the specified list items, and the specified HMTL attributes.
public static MvcHtmlString ListBox(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributesIDictionary<string, object>An object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element with an option subelement for each item in the list..
Exceptions
- ArgumentException
The
nameparameter is null or empty.
ListBox(HtmlHelper, string, IEnumerable<SelectListItem>, object)
Returns a multi-select select element using the specified HTML helper, the name of the form field, and the specified list items.
public static MvcHtmlString ListBox(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, object htmlAttributes)
Parameters
htmlHelperHtmlHelperThe HTML helper instance that this method extends.
namestringThe name of the form field to return.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributesobjectAn object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element with an option subelement for each item in the list..
Exceptions
- ArgumentException
The
nameparameter is null or empty.
ListBoxFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>)
Returns an HTML select element for each property in the object that is represented by the specified expression and using the specified list items.
public static MvcHtmlString ListBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
Returns
- MvcHtmlString
An HTML select element for each property in the object that is represented by the expression.
Type Parameters
TModelThe type of the model.
TPropertyThe type of the property.
Exceptions
- ArgumentNullException
The
expressionparameter is null.
ListBoxFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, IDictionary<string, object>)
Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items and HTML attributes.
public static MvcHtmlString ListBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributesIDictionary<string, object>An object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element for each property in the object that is represented by the expression.
Type Parameters
TModelThe type of the model.
TPropertyThe type of the property.
Exceptions
- ArgumentNullException
The
expressionparameter is null.
ListBoxFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable<SelectListItem>, object)
Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items and HTML attributes.
public static MvcHtmlString ListBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, object htmlAttributes)
Parameters
htmlHelperHtmlHelper<TModel>The HTML helper instance that this method extends.
expressionExpression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectListIEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributesobjectAn object that contains the HTML attributes to set for the element.
Returns
- MvcHtmlString
An HTML select element for each property in the object that is represented by the expression.
Type Parameters
TModelThe type of the model.
TPropertyThe type of the property.
Exceptions
- ArgumentNullException
The
expressionparameter is null.