I have a page with two text boxes on it. The data item of the template form is bound to an instance of class MyTest which is defined as:
public class MyTest
{
public int Id { get; set; }
public MyTestChild ChildOne { get; set; }
public MyTestChild ChildTwo { get; set; }
}
public class MyTestChild
{
public string ChildText {get; set; }
}
The name of the instance of MyTest2 is GetTestData. I have initialized the
instance with the following statement:
GetTestData = new MyTest
{
ChildOne = new MyTestChild(),
ChildTwo = new MyTestChild()
};
The first text box is bound to GetTestData.ChildOne.ChildText.
The second text box is bound to GetTestData.ChildTwo.ChildText.
Each text box has its own required validator.
When I am running my application and entering a value in the first text box,
the required validator of the second textbox is fired.
I was then making a refresh and left the first text box empty and entering
a value in the second text box. Now the required validator of the first box
is firing.
This problem only happens when an instance of class A is used which have two or more properties which are instances of class B.
Do you have any solution for this ?
Here is the source code of the page:
@page "/testme/add"
@layout MainLayout
@using Radzen
@using Radzen.Blazor
@using AlarmService.Data
<RadzenContent Container="main">
<ChildContent>
<div class="row">
<div class="col-md-12">
<RadzenTemplateForm Data="@GetTestData" Visible="@(GetTestData != null)" TItem="MyTest" Submit="@SubmitData">
<ChildContent>
<div style="margin-bottom: 1.5rem" class="row">
<div class="col-md-3">
<RadzenLabel Text="Text 1" Component="tbText1" style="width: 100%">
</RadzenLabel>
</div>
<div class="col-md-9">
<RadzenTextBox MaxLength="100" style="display: block; width: 100%" @bind-Value="@(GetTestData.ChildOne.ChildText)" Name="tbText1">
</RadzenTextBox>
<RadzenRequiredValidator Component="tbText1" style="position: absolute">
</RadzenRequiredValidator>
</div>
</div>
<div style="margin-bottom: 1.5rem" class="row">
<div class="col-md-3">
<RadzenLabel Text="Text 2" Component="tbText2" style="width: 100%">
</RadzenLabel>
</div>
<div class="col-md-9">
<RadzenTextBox MaxLength="100" style="display: block; width: 100%" @bind-Value="@(GetTestData.ChildTwo.ChildText)" Name="tbText2" >
</RadzenTextBox>
<RadzenRequiredValidator Component="tbText2" style="position: absolute">
</RadzenRequiredValidator>
</div>
</div>
<div class="row">
<div class="col offset-sm-3">
<RadzenButton ButtonType="ButtonType.Submit" Icon="save" Text="Save" ButtonStyle="ButtonStyle.Primary">
</RadzenButton>
<RadzenButton ButtonStyle="ButtonStyle.Light" style="margin-left: 1rem" Text="Cancel" Click="@ButtonCancelClick" >
</RadzenButton>
</div>
</div>
</ChildContent>
</RadzenTemplateForm>
</div>
</div>
</ChildContent>
</RadzenContent>