Skip to content

FormSelectTagHelper

StrutTower edited this page Nov 12, 2022 · 4 revisions

Similar to FormFieldTagHelper except this tag helper is for select lists

Usage

<formSelect asp-for="Property" asp-items="SelectList"></formSelect>

Output

<div class="mb-3">
    <label for="Property">Property Display Name</label>
    <select name="Property" id="Property>
        <option value=""></option>
        <option value="1">First Option</option>
        <option value="2">Second Option</option>
    </select>
    <span>[Validation placeholder]</span>
    <div class="text-muted ps-2 small">Description</div>
</div>

Attributes

Name Required Data type Description
asp-for Required ModelExpression
asp-items Required SelectList
asp-option-label Optional String (default: "") The null or blank option in the select list. Set to null to exclude that option from the select list.
label Optional String Overrides the label for the field
multiple Optional Boolean (default: false) Sets if the select will allow multiple selected items.

Clone this wiki locally