Skip to content
Advertisement

Blazor Server-side Restart the app @onclick event

Blazor Forms Calculator that takes inputs and calculates numbers. At the end I have two buttons, Download PDF (with the results) and New Calculation that will restart the application.

<button @onclick=Print style="background-color:green;">
    Download PDF
</button>
<button  style="background-color:green;">
    New Calculation
</button>

Can I do that with the @onclick event or call a Javascript function?

Advertisement

Answer

I have used Navigation Manager and have navigated the app on the Index page

    private void HandleClick()
{
    NavigationManager.NavigateTo("/", true);
}

calling it on click

    <button @onclick=HandleClick style="background-color:green;" class="btn btn- 
        primary btn-medium hidewhenprint">
     New Calculation
        </button>
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement