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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
Returns
- MvcHtmlString
An HTML select element.
Exceptions
- ArgumentException
The
name
parameter 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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
selectList
IEnumerable<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
name
parameter 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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributes
IDictionary<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
name
parameter 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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributes
objectAn 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
name
parameter 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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabel
stringThe 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
name
parameter 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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabel
stringThe text for a default empty item. This parameter can be null.
htmlAttributes
IDictionary<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
name
parameter 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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabel
stringThe text for a default empty item. This parameter can be null.
htmlAttributes
objectAn 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
name
parameter 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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
optionLabel
stringThe 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
name
parameter 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectList
IEnumerable<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
TModel
The type of the model.
TProperty
The type of the value.
Exceptions
- ArgumentNullException
The
expression
parameter 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributes
IDictionary<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
TModel
The type of the model.
TProperty
The type of the value.
Exceptions
- ArgumentNullException
The
expression
parameter 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributes
objectAn 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
TModel
The type of the model.
TProperty
The type of the value.
Exceptions
- ArgumentNullException
The
expression
parameter 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabel
stringThe 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
TModel
The type of the model.
TProperty
The type of the value.
Exceptions
- ArgumentNullException
The
expression
parameter 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabel
stringThe text for a default empty item. This parameter can be null.
htmlAttributes
IDictionary<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
TModel
The type of the model.
TProperty
The type of the value.
Exceptions
- ArgumentNullException
The
expression
parameter 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
optionLabel
stringThe text for a default empty item. This parameter can be null.
htmlAttributes
objectAn 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
TModel
The type of the model.
TProperty
The type of the value.
Exceptions
- ArgumentNullException
The
expression
parameter 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<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
TModel
The type of the model.
TEnum
The 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TEnum>>An expression that identifies the object that contains the values to display.
htmlAttributes
IDictionary<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
TModel
The type of the model.
TEnum
The 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TEnum>>An expression that identifies the object that contains the values to display.
htmlAttributes
objectAn 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
TModel
The type of the model.
TEnum
The 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TEnum>>An expression that identifies the object that contains the values to display.
optionLabel
stringThe 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
TModel
The type of the model.
TEnum
The 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TEnum>>An expression that identifies the object that contains the values to display.
optionLabel
stringThe text for a default empty item. This parameter can be null.
htmlAttributes
IDictionary<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
TModel
The type of the model.
TEnum
The 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TEnum>>An expression that identifies the object that contains the values to display.
optionLabel
stringThe text for a default empty item. This parameter can be null.
htmlAttributes
objectAn 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
TModel
The type of the model.
TEnum
The 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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
Returns
- MvcHtmlString
An HTML select element.
Exceptions
- ArgumentException
The
name
parameter 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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
selectList
IEnumerable<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
name
parameter 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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributes
IDictionary<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
name
parameter 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
htmlHelper
HtmlHelperThe HTML helper instance that this method extends.
name
stringThe name of the form field to return.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributes
objectAn 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
name
parameter 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectList
IEnumerable<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
TModel
The type of the model.
TProperty
The type of the property.
Exceptions
- ArgumentNullException
The
expression
parameter 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributes
IDictionary<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
TModel
The type of the model.
TProperty
The type of the property.
Exceptions
- ArgumentNullException
The
expression
parameter 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
htmlHelper
HtmlHelper<TModel>The HTML helper instance that this method extends.
expression
Expression<Func<TModel, TProperty>>An expression that identifies the object that contains the properties to display.
selectList
IEnumerable<SelectListItem>A collection of SelectListItem objects that are used to populate the drop-down list.
htmlAttributes
objectAn 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
TModel
The type of the model.
TProperty
The type of the property.
Exceptions
- ArgumentNullException
The
expression
parameter is null.