G
GZERO1
Guest
Hi,
Inquiry
I want to try to display a popup modal dialog box in the browser using JS interop, but I can't make this code work:
@page "/counter"
@inject IJSRuntime JsRuntime
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
<button class="btn btn-info" @onclick="(() => JsInvokeThis(currentCount))">Invoke</button>
@code {
int currentCount = 0;
void IncrementCount()
{
currentCount++;
}
async Task JsInvokeThis(int count)
{
await JsRuntime.InvokeAsync<string>("count", $"count is {count}"); // <-- this line does not work
}
}
The above code does nothing.
Background
1. I'm a beginner and trying to learn Blazor EF Core 3.0
2. Currently using Visual Studio 2019 v16.3.0 (newly installed)
Continue reading...
Inquiry
I want to try to display a popup modal dialog box in the browser using JS interop, but I can't make this code work:
@page "/counter"
@inject IJSRuntime JsRuntime
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
<button class="btn btn-info" @onclick="(() => JsInvokeThis(currentCount))">Invoke</button>
@code {
int currentCount = 0;
void IncrementCount()
{
currentCount++;
}
async Task JsInvokeThis(int count)
{
await JsRuntime.InvokeAsync<string>("count", $"count is {count}"); // <-- this line does not work
}
}
The above code does nothing.
Background
1. I'm a beginner and trying to learn Blazor EF Core 3.0
2. Currently using Visual Studio 2019 v16.3.0 (newly installed)
Continue reading...