Share via


IHtmlGenerator.GenerateSelect Method

Definition

Overloads

GenerateSelect(ViewContext, ModelExplorer, String, String, IEnumerable<SelectListItem>, Boolean, Object)

Generate a <select> element for the expression.

GenerateSelect(ViewContext, ModelExplorer, String, String, IEnumerable<SelectListItem>, ICollection<String>, Boolean, Object)

Generate a <select> element for the expression.

GenerateSelect(ViewContext, ModelExplorer, String, String, IEnumerable<SelectListItem>, Boolean, Object)

Source:
IHtmlGenerator.cs

Generate a <select> element for the expression.

public:
 Microsoft::AspNetCore::Mvc::Rendering::TagBuilder ^ GenerateSelect(Microsoft::AspNetCore::Mvc::Rendering::ViewContext ^ viewContext, Microsoft::AspNetCore::Mvc::ViewFeatures::ModelExplorer ^ modelExplorer, System::String ^ optionLabel, System::String ^ expression, System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Mvc::Rendering::SelectListItem ^> ^ selectList, bool allowMultiple, System::Object ^ htmlAttributes);
public Microsoft.AspNetCore.Mvc.Rendering.TagBuilder GenerateSelect (Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext, Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer modelExplorer, string optionLabel, string expression, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> selectList, bool allowMultiple, object htmlAttributes);
abstract member GenerateSelect : Microsoft.AspNetCore.Mvc.Rendering.ViewContext * Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer * string * string * seq<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> * bool * obj -> Microsoft.AspNetCore.Mvc.Rendering.TagBuilder
Public Function GenerateSelect (viewContext As ViewContext, modelExplorer As ModelExplorer, optionLabel As String, expression As String, selectList As IEnumerable(Of SelectListItem), allowMultiple As Boolean, htmlAttributes As Object) As TagBuilder

Parameters

viewContext
ViewContext

A ViewContext instance for the current scope.

modelExplorer
ModelExplorer

ModelExplorer for the expression. If null, determines validation attributes using viewContext and the expression.

optionLabel
String

Optional text for a default empty <option> element.

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, finds this collection at ViewContext.ViewData[expression].

allowMultiple
Boolean

If true, includes a multiple attribute in the generated HTML. Otherwise generates a single-selection <select> element.

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 TagBuilder describing the <select> element.

Remarks

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

See GetCurrentValues(ViewContext, ModelExplorer, String, Boolean) for information about how current values are determined.

Applies to

GenerateSelect(ViewContext, ModelExplorer, String, String, IEnumerable<SelectListItem>, ICollection<String>, Boolean, Object)

Source:
IHtmlGenerator.cs

Generate a <select> element for the expression.

public:
 Microsoft::AspNetCore::Mvc::Rendering::TagBuilder ^ GenerateSelect(Microsoft::AspNetCore::Mvc::Rendering::ViewContext ^ viewContext, Microsoft::AspNetCore::Mvc::ViewFeatures::ModelExplorer ^ modelExplorer, System::String ^ optionLabel, System::String ^ expression, System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Mvc::Rendering::SelectListItem ^> ^ selectList, System::Collections::Generic::ICollection<System::String ^> ^ currentValues, bool allowMultiple, System::Object ^ htmlAttributes);
public Microsoft.AspNetCore.Mvc.Rendering.TagBuilder GenerateSelect (Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext, Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer modelExplorer, string optionLabel, string expression, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> selectList, System.Collections.Generic.ICollection<string> currentValues, bool allowMultiple, object htmlAttributes);
abstract member GenerateSelect : Microsoft.AspNetCore.Mvc.Rendering.ViewContext * Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer * string * string * seq<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> * System.Collections.Generic.ICollection<string> * bool * obj -> Microsoft.AspNetCore.Mvc.Rendering.TagBuilder
Public Function GenerateSelect (viewContext As ViewContext, modelExplorer As ModelExplorer, optionLabel As String, expression As String, selectList As IEnumerable(Of SelectListItem), currentValues As ICollection(Of String), allowMultiple As Boolean, htmlAttributes As Object) As TagBuilder

Parameters

viewContext
ViewContext

A ViewContext instance for the current scope.

modelExplorer
ModelExplorer

ModelExplorer for the expression. If null, determines validation attributes using viewContext and the expression.

optionLabel
String

Optional text for a default empty <option> element.

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, finds this collection at ViewContext.ViewData[expression].

currentValues
ICollection<String>

An ICollection<T> containing values for <option> elements to select. If null, selects <option> elements based on Selected values in selectList.

allowMultiple
Boolean

If true, includes a multiple attribute in the generated HTML. Otherwise generates a single-selection <select> element.

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 TagBuilder describing the <select> element.

Remarks

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

See GetCurrentValues(ViewContext, ModelExplorer, String, Boolean) for information about how the currentValues collection may be created.

Applies to