Two-way binding is having a bidirectional data flow, i.e., passing the value from the property to the UI and then from the view (UI) to the property. Blazor provides support for two-way binding using the bind attribute.

Syntax for creating two-way binding property:


Note: Must enclose “InputDate” field in a “EditForm”.

<EditForm Model="@_test">
    <InputDate @bind-Value="_test.DateValue" />

<br />

<p>Selected Date: @_test.DateValue.ToLongDateString()</p>

@code {
    public class TestClass
        public DateTime DateValue { get; set; }

    private TestClass _test = new TestClass();


Last modified: November 22, 2020



Write a Reply or Comment