I have a MudCheckBox and a MudTextField on my form. When I fill the value of MudTextField in first and than I click on the MudCheckBox the value of the MudTextField is cleared. In reverse order, this is not true. https://try.mudblazor.com/snippet/mEQoYyutzaycRzeM How can I preserve the value of the MudTextField, please?
You have to change the value of the variable. For now only the Text value of the Textfield has been changed, but not the variable itself. Clicking a checkbox causes the component to rerender and write the unchanged variable to the textfield.
Either use @bind-Text
(or @bind-Value
) or the EventCallback TextChanged
(ValueChanged
).
<MudTextField T="string" Label="Note" Variant="Variant.Text" @bind-Text="@Note" Lines="2" AutoGrow MaxLines="4" />
<MudCheckBox @bind-Value="@Basic_CheckBox1"></MudCheckBox>