I want to show alert after a button click in Blazor. Below is the html and server side code
<div class="form-group col-md-12 ">
<button class="btn btn-primary" @onclick="InsertForecast"> Submit</button>
</div>
public async Task InsertForecast()
{
//want to add the alert here
bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?");
}
I tried adding using Microsoft.JSInterop
in the code behind file but the JsRuntime
object giving the following error
Object does not contain a definition for InvokeAsync and the best extension method overload JSObjectreferenceExtension.InvokeAsync expects parameter of type 'IJsObjectreference'