mirror of
https://github.com/PacktPublishing/Web-Development-with-Blazor-Second-Edition.git
synced 2025-12-06 05:32:03 +01:00
32 lines
786 B
Plaintext
32 lines
786 B
Plaintext
@page "/bind-get-set"
|
|
@using Microsoft.AspNetCore.Components.Forms
|
|
|
|
<h1>Bind Get Set Examples</h1>
|
|
|
|
<h2>Elements</h2>
|
|
|
|
<input type="text" @bind:get="text" @bind:set="(value) => { text = value; }" />
|
|
|
|
<input type="text" @bind:get="text" @bind:set="Set" />
|
|
|
|
<input type="text" @bind:get="text" @bind:set="SetAsync" />
|
|
|
|
<h2>Components</h2>
|
|
|
|
|
|
<InputText @bind-Value="text" />
|
|
|
|
<InputText @bind-Value:get="text" @bind-Value:set="(value) => {text=value; }" />
|
|
<InputText @bind-Value:get="text" @bind-Value:set="Set" />
|
|
<InputText @bind-Value:get="text" @bind-Value:set="SetAsync" />
|
|
|
|
@code {
|
|
private string text = "";
|
|
|
|
private void Set(string value) { text = value; }
|
|
private Task SetAsync(string value)
|
|
{
|
|
text = value;
|
|
return Task.CompletedTask;
|
|
}
|
|
} |