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.

Revisions

  1. jabed-web-dev created this gist Nov 14, 2022.
    22 changes: 22 additions & 0 deletions blazorserver-console.log.razor
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    <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);
    }
    }