Skip to content

Additional information regarding restrictions of events that can be used with @bind:event is needed #35976

@georgehemmings

Description

@georgehemmings

Description

Bind a property or field on other DOM events by including an @bind:event="{EVENT}" attribute with a DOM event for the {EVENT} placeholder. The following example binds the InputValue property to the <input> element's value when the element's oninput event ([input](https://developer.mozilla.org/docs/Web/API/HTMLElement/input_event)) is triggered. Unlike the onchange event ([change](https://developer.mozilla.org/docs/Web/API/HTMLElement/change_event)), which fires when the element loses focus, oninput ([input](https://developer.mozilla.org/docs/Web/API/HTMLElement/input_event)) fires when the value of the text box changes.

This sections makes it seem like you can use any DOM EVENT as the trigger for binding. It only works with oninput and onchange as far as I can tell. onkeydown doesn't work for example. Internally it looks like the DOM EVENT must be mapped to the ChangeEventArgs class for the event to work.

It also doesn't call out that the "on" prefix is needed before the DOM EVENT name.

Thanks
George

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/components/data-binding?view=aspnetcore-10.0&preserve-view=true

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/components/data-binding.md

Document ID

3f912dfc-5ba5-6c6c-ba93-1ae78508a5cc

Platform Id

ad2f661d-d520-a055-4a4e-26b9520e6ce3

Article author

@guardrex

Metadata

  • ID: b211df59-e1c9-86c0-c904-31fa3c361e6d
  • PlatformId: ad2f661d-d520-a055-4a4e-26b9520e6ce3
  • Service: aspnet-core
  • Sub-service: blazor

Related Issues

Metadata

Metadata

Assignees

Type

No type

Projects

Status

P0/P1 - High Priority

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions