You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

34 lines
668 B

@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();
}
}