Skip to content

[Blazor] Ability to add a callback on the default onchange when Using @bind #21892

Closed
@mrlife

Description

@mrlife

Is your feature request related to a problem? Please describe.

When working with Entity Framework Core in Blazor, it would be convenient to be able to bind to a tracked property so that when the element representing the property is changed, the change can be saved via Entity Framework Core as well.

Describe the solution you'd like

<input type="checkbox" id="checkboxIsFavorite" @bind="User.IsFavorite" @onchange-callback="SaveContext">

@code {
    [Parameter]
    public Record User { get; set; } // this is already being tracked by EF Core

    // this function is called after the default onchange completes
    private async Task SaveContext() {
        // code that simply saves the db context, which will save the change to User.IsFavorite
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions