Live Chat Icon For mobile
Live Chat Icon

How do you render a Blazor page after the parameter is updated?

Platform: Blazor| Category: General

Blazor updates the UI every time a parameter updates. Invoking an external StateHasChanged() might be required when updating parameters as a result of any async operation.


@page "/counter" 
<p role="status">Current count: @currentCount</p> 
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> 

@code { 
    public int currentCount { get; set; } = 0; 
    private async Task IncrementCount () 
        // Call StateHasChanged to trigger a re-render of the page 
        await InvokeAsync(StateHasChanged); 

StateHasChanged tells Blazor to update the UI when it is called.

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.