dotnet/aspnetcore

Support asp-items for datalist element

Open

#7,663 建立於 2019年2月17日

在 GitHub 查看
 (21 留言) (21 反應) (0 負責人)C# (10,653 fork)batch import
Priority:2affected-mediumarea-mvcenhancementfeature-mvc-razor-viewshelp wantedseverity-minor

倉庫指標

Star
 (37,933 star)
PR 合併指標
 (平均合併 16天 9小時) (30 天內合併 258 個 PR)

描述

The <datalist> element can be used to create a HTML-only "type-to-select" drop-down list (aka combobox with input enabled).

The elements with the <datalist> tag are of type <option>, just like those that would be in a <select> list, which is supported by the asp-items Razor tag helper.

e.g. it would be great to be able to turn

<select asp-for="Customer" asp-items="Customers"></select>

into

<input list="customers" asp-for="Model.Customer" />
<datalist id="customers" asp-items="Model.Customers"></datalist>

But perhaps it would be necessary for the tags to be coalesced into one, so that one need not type out and match the id tag, in which case it might look something like this:

<input asp-for="Model.Customer" asp-items="Model.Customers" />

貢獻者指南