mirror of
https://github.com/PacktPublishing/Web-Development-with-Blazor-Second-Edition.git
synced 2025-12-06 05:32:03 +01:00
18 lines
431 B
Plaintext
18 lines
431 B
Plaintext
|
|
@page "/nettojswasm"
|
||
|
|
@using System.Runtime.InteropServices.JavaScript
|
||
|
|
|
||
|
|
<h3>This is a demo how to call JavaScript from .NET</h3>
|
||
|
|
|
||
|
|
<button @onclick="ShowAlert">Show Alert</button>
|
||
|
|
@code {
|
||
|
|
protected async void ShowAlert()
|
||
|
|
{
|
||
|
|
ShowAlert("Hello from .NET");
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override async Task OnInitializedAsync()
|
||
|
|
{
|
||
|
|
await JSHost.ImportAsync("nettojs", "../JSInteropSamples/NetToJS.razor.js");
|
||
|
|
}
|
||
|
|
}
|