StaticSelect
Abstract
Inherits: StaticInputBase
Section titled “ProcessAsync(TagHelperContext context, TagHelperOutput output)”
StaticSelect is the headless base class for <select> components. It adds an
Items property mapped from the consumer-facing asp-items attribute, so
consumers can supply options exactly as they would to a native <select>.
Inside the component’s Razor template, bind the inner <select> via the
static-for and static-items tag helpers.
Namespace
Section titled “Namespace”TechGems.StaticComponents.Headlessusing TechGems.StaticComponents.Headless;
namespace YourAssembly.Views.Components;
public class PinesSelect : StaticSelect { }@* ~/Views/Components/PinesSelect.cshtml *@@model PinesSelect
<select static-for="@Model.InputExpression" static-items="@Model.Items" disabled="@(Model.Disabled ? "disabled" : null)" class="…"></select>@* consumer view *@<pines-select asp-for="Form.Department" asp-items="@Model.DepartmentOptions"></pines-select>Public Properties
Section titled “Public Properties”[HtmlAttributeName("asp-items")]public List<SelectListItem> Items { get; set; } = new List<SelectListItem>();The list of SelectListItems rendered as <option> tags inside the inner
<select>. Items that share a SelectListGroup reference are grouped into a
single <optgroup> at the position of the group’s first occurrence.
| Attribute | Value |
|---|---|
| HTML attribute | asp-items |
| Required | No |
| Default | empty list |
Inherited Properties
Section titled “Inherited Properties”InputExpression(asp-for)ShowLabel(show-label)Disabled(disabled)
See StaticInputBase for the full descriptions.
Methods
Section titled “Methods”ProcessAsync(TagHelperContext context, TagHelperOutput output)
Section titled “ProcessAsync(TagHelperContext context, TagHelperOutput output)”public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)Delegates to StaticInputBase.ProcessAsync.
Related
Section titled “Related”- Headless Components — Feature guide.
- StaticInputBase
- StaticSelectTagHelper