Reputation: 31
@inject IJSRuntime _runtime;
<Button Clicked="OnUniClick">
<Figure Size="FigureSize.Is128x128" Rounded>
<FigureImage Source="@Logo" AlternateText="@Name" />
<FigureCaption>@Name</FigureCaption>
</Figure>
</Button>
@code {
[Parameter]
public string Logo { get; set; }
[Parameter]
public string Name { get; set; }
public async Task OnUniClick()
{
Console.WriteLine("Clicked");
await _runtime.InvokeVoidAsync("alert", "This is a test alert");
}
}
Neither the Console.WriteLine or the alert execute when the button is clicked. This is my first time using Blazor and I am just trying to get a JavaScript alert to pop up. I believe that I am following everything described in these three posts:
Upvotes: 0
Views: 166
Reputation: 30167
This looks like Net8 rendering in Static SSR mode? You need to check the @rendermode
directive set on the page or on App.razor
.
Upvotes: 1