I'm trying to implement an alert message within a Blazor component, but I'm unsure of the correct approach. My project is using ASP.NET Core 3.1 with Blazor server-side. Here's what I have attempted:
Component function:
private async Task ShowAlert()
{
await JSRuntime.InvokeAsync<object>("ShowMsg");
}
Javascript Interop:
function ShowMsg() {
success = "Success!";
return success;
}
File host.cshtml
:
<script src="~/BlazorInterop.js"></script>