Skip to content

Instantly share code, notes, and snippets.

@jabed-web-dev
Created November 14, 2022 15:24
Show Gist options
  • Select an option

  • Save jabed-web-dev/012d4434bfb8d86a8bd393e4b9c33a2d to your computer and use it in GitHub Desktop.

Select an option

Save jabed-web-dev/012d4434bfb8d86a8bd393e4b9c33a2d to your computer and use it in GitHub Desktop.
blazor server log to browser console
<h1>Counter</h1>
<p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
[Inject]
public IJSRuntime JSRuntime { get; set; } = null!;
public async void ConsoleLog(int arg)
{
await JSRuntime.InvokeVoidAsync("console.log", arg);
}
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
ConsoleLog(currentCount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment