Web-Development-with-Blazor.../Chapter13/MyBlog/Components/Pages/JSInteropSamples/JSToStaticNET.razor
2023-02-17 15:28:17 +01:00

17 lines
489 B
Plaintext

@page "/jstostaticnet"
<h3>This is a demo how to call .NET from JavaScript</h3>
@*
Note that we are using the JavaScript onclick parameter not the @onclick
The JavaScript file JSToStaticNET.js is included in the _layout/index page.
*@
<button onclick="callnetfromjs()">Show alert with message</button>
@code {
[JSInvokable("NameOfTheMethod")]
public static Task<string> GetAMessageFromNET()
{
return Task.FromResult("This is a message from .NET");
}
}