Child component to parent component communication

The parent component assigns a callback method to the child component’s event. In Blazor, to expose an event we use EventCallback.

[Parameter]
public EventCallback<int> OnEmployeeDeleted { get; set; }

protected async Task Delete_Click()
{
    await EmployeeService.DeleteEmployee(Employee.EmployeeId);
    await OnEmployeeDeleted.InvokeAsync(Employee.EmployeeId);
    //NavigationManager.NavigateTo("/", true);
}

Sources:

https://www.pragimtech.com/blog/blazor/pass-data-from-child-to-parent-component-in-blazor/

Last modified: April 8, 2021

Author

Comments

Write a Reply or Comment