This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Tag Helpers: <option/>
tag helper #1423
Closed
Description
Current <select/>
tag helper only sets selected
attributes for <option/>
elements generated from the items
enumeration. Should support adding this attribute to <option/>
elements users provide. E.g. f the Razor source contains
<select for="YearsEmployeed">
<option value="">Why didn't you select anything?</option>
<option value="0">Less than 1</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
the generated code should select the <option value="1">
element when Model.YearsEmployed
is 1
.
As an added bonus, could perform no automatic selection if the user explicitly provides a selected
attribute on one of their options. E.g. if the Razor source contains
<select for="YearsEmployeed" items="SelectList">
<option value="">Why didn't you select anything?</option>
<option value="0">Less than 1</option>
<option value="1">1</option>
<option value="2" selected="selected">2</option>
<option value="3">3</option>
</select>
the generated code should include only a single selected
attribute even if SelectList
contains a SelectListItem
for 4
and that's the current Model.YearsEmployed
value.
If we decide to support this enhancement, it may need to be tracked as a separate issue.