35 lines
668 B
Plaintext
35 lines
668 B
Plaintext
@page "/jsinterop"
|
|
@inject IJSRuntime _jsRuntime;
|
|
|
|
<h3>JSInterop</h3>
|
|
|
|
<div>
|
|
<button type="button" class="btn btn-primary" @onclick="HelloWorld">
|
|
Hello World!
|
|
</button>
|
|
</div>
|
|
|
|
<br />
|
|
|
|
<div>
|
|
<button type="button" class="btn btn-primary" @onclick="InputName">
|
|
Input Name
|
|
</button>
|
|
<p>@_name</p>
|
|
</div>
|
|
|
|
@code {
|
|
string _name;
|
|
|
|
private async void HelloWorld()
|
|
{
|
|
await _jsRuntime.InvokeVoidAsync("testFunction.helloWorld", null);
|
|
}
|
|
|
|
private async void InputName()
|
|
{
|
|
_name = await _jsRuntime.InvokeAsync<string>("testFunction.inputName", "Send from Blazor");
|
|
StateHasChanged();
|
|
}
|
|
}
|