How do I make two-way binding in Blazor?

Platform: Blazor| Category: Data binding

In two-way binding, data moves from the component to the UI and from the UI to the component class. Use the @bind attribute in the property to bind two ways in Blazor. By default, the bind attribute binds the data in the OnChange event. The OnChange event triggers when the element loses focus.

Follow these steps to achieve the two-way binding in Blazor.

<div>
    <input @bind="BindValue" @bind:event="oninput" />
</div>
<div>
    Binding Value : @BindValue
</div>

@code {
    public string BindValue { get; set; } = string.Empty;
}

Refer to this link for more details.

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.