Q:

How do I suppress the UI rendering in Blazor?

1

This code will help you to understand how to suppress the UI rendering in Blazor.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Override the ShouldRender method to suppress UI rendering. If the implementation returns true, the UI is refreshed. Initial rendering cannot be prevented using this method.

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
 
@code {
    private int currentCount = 0;
    private bool shouldRender = true;
 
    private void IncrementCount()
    {
        shouldRender = false;
        currentCount++;
    }
 
    protected override bool ShouldRender()
    {
        return shouldRender;
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now