Components topic code example updates (#12893)
parent
4ce108f514
commit
692fb252b6
|
@ -21,7 +21,7 @@
|
|||
_italicsCheck field.
|
||||
*@
|
||||
<input type="checkbox" id="italicsCheck"
|
||||
@bind="@_italicsCheck" />
|
||||
@bind="_italicsCheck" />
|
||||
<label class="form-check-label"
|
||||
for="italicsCheck">Use italics</label>
|
||||
</div>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<h4>Greetings from the first tab!</h4>
|
||||
|
||||
<label>
|
||||
<input type="checkbox" @bind="@showThirdTab" />
|
||||
<input type="checkbox" @bind="showThirdTab" />
|
||||
Toggle third tab
|
||||
</label>
|
||||
</Tab>
|
||||
|
@ -49,7 +49,7 @@ namespace BlazorSample.UIInterfaces
|
|||
<h4>Greetings from the first tab!</h4>
|
||||
|
||||
<label>
|
||||
<input type="checkbox" @@bind="@@showThirdTab" />
|
||||
<input type="checkbox" @@bind="showThirdTab" />
|
||||
Toggle third tab
|
||||
</label>
|
||||
</Tab>
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
@@*
|
||||
A check box sets the font style and is bound to the _italicsCheck field.
|
||||
*@@
|
||||
<input type="checkbox" id="italicsCheck" @@bind="@@_italicsCheck" />
|
||||
<input type="checkbox" id="italicsCheck" @@bind="_italicsCheck" />
|
||||
<label class="form-check-label" for="italicsCheck">Use italics</label>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ description: Learn how to create and use Razor components, including how to bind
|
|||
monikerRange: '>= aspnetcore-3.0'
|
||||
ms.author: riande
|
||||
ms.custom: mvc
|
||||
ms.date: 06/12/2019
|
||||
ms.date: 06/16/2019
|
||||
uid: blazor/components
|
||||
---
|
||||
# Create and use Razor components
|
||||
|
@ -139,13 +139,13 @@ Using `@bind` with a `CurrentValue` property (`<input @bind="CurrentValue" />`)
|
|||
|
||||
When the component is rendered, the `value` of the input element comes from the `CurrentValue` property. When the user types in the text box, the `onchange` event is fired and the `CurrentValue` property is set to the changed value. In reality, the code generation is a little more complex because `@bind` handles a few cases where type conversions are performed. In principle, `@bind` associates the current value of an expression with a `value` attribute and handles changes using the registered handler.
|
||||
|
||||
In addition to `onchange`, the property can be bound using other events like `oninput` by adding a `@bind` attribute with an `event` parameter:
|
||||
In addition to handling `onchange` events with `@bind` syntax, a property or field can be bound using other events by specifying an `@bind-value` attribute with an `event` parameter. The following example binds the `CurrentValue` property for the `oninput` event:
|
||||
|
||||
```cshtml
|
||||
<input type="text" @bind-value="@CurrentValue" @bind-value:event="oninput" />
|
||||
<input @bind-value="CurrentValue" @bind-value:event="oninput" />
|
||||
```
|
||||
|
||||
Unlike `onchange`, `oninput` fires for every character that is input into the text box.
|
||||
Unlike `onchange`, which fires when the element loses focus, `oninput` fires when the value of the text box changes.
|
||||
|
||||
**Format strings**
|
||||
|
||||
|
|
Loading…
Reference in New Issue