Skip to content

Support binding to <select multiple>, getting/setting the selection as an array #5519

@dlr1

Description

@dlr1

With the following code

 <select name="cars" multiple onchange="@SelectionChanged">
        <option value="volvo">Volvo</option>
        <option value="saab">Saab</option>
        <option value="opel">Opel</option>
        <option value="audi">Audi</option>
    </select>
 void SelectionChanged(UIChangeEventArgs e)
        {
            Console.WriteLine(e.Value);
        }

Holding down the ctrl key, if you select 'volvo' first and then any other value, e.value is always 'volvo'. It basically returns the top selected item in the list.

Metadata

Metadata

Assignees

Labels

DoneThis issue has been fixedPriority:2Work that is important, but not critical for the releaseUser StoryA single user-facing feature. Can be grouped under an epic.affected-mostThis issue impacts most of the customersarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-razor.languageseverity-majorThis label is used by an internal tool

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions