Skip to content

Instantly share code, notes, and snippets.



Last active May 8, 2020
What would you like to do?
@page "/counter"
@inject IJSRuntime js
<p>Current count: @currentCount</p>
<button id="counterClick" class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
protected async override Task OnAfterRenderAsync(bool firstRender)
if (firstRender)
await js.InvokeVoidAsync("initializeCounterComponent");
private void IncrementCount()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment