I'm using Blazor 19.3 server side and this is a piece of code from your examples where I added an error message to the [required] dataannotations.
The problem is that the error message is never showed when I try to confirm an empty textbox
When the "required" is triggered in the InPlaceEditor ?
Supposing I have in the page a lot of InPlaceEditor components, how can I validate all of them clicking on a button ?
Thanks
<table class="table-section">
<tr>
<td class="sample-td"> Enter your name: </td>
<td class="sample-td">
<SfInPlaceEditor @bind-Value="exampleModel.Name" Type="Syncfusion.Blazor.InPlaceEditor.InputType.Text" TValue="string">
<EditorComponent>
<EditForm Model="@exampleModel">
<DataAnnotationsValidator />
<SfTextBox @bind-Value="exampleModel.Name"></SfTextBox>
<ValidationMessage For=@(() => exampleModel.Name) />
</EditForm>
</EditorComponent>
</SfInPlaceEditor>
</td>
</tr>
</table>
@code {
private string primaryKey { get; set; } = "editor1";
private ExampleModel exampleModel = new ExampleModel();
public class ExampleModel
{
[Required(ErrorMessage = "Insert a value")]
[StringLength(10, ErrorMessage = "Name is too long.")]
public string Name { get; set; }
}
}
Sorry for the inconvenience caused,
We are unable to include the fix, for the
reported issue with our patch release on 28th December due to its
complexity. We will include the fix with our patch release on January 11th
2022.
We couldn't include the fix for the issue due to its complexity. We will include the fix with our upcoming patch release on 25th January 2022.
|
<SfInPlaceEditor @bind-Value="exampleModel.Name" Type="Syncfusion.Blazor.InPlaceEditor.InputType.Text" TValue="string">
<EditorComponent>
<EditForm Model="@exampleModel" Context="editContext">
<DataAnnotationsValidator />
<SfTextBox @bind-Value="exampleModel.Name"></SfTextBox>
<ValidationMessage For=@(() => exampleModel.Name) />
<InPlaceEditorEvents TValue="string" EndEdit="@((e)=>EndEditEvent(e, editContext))"></InPlaceEditorEvents>
</EditForm>
</EditorComponent>
</SfInPlaceEditor>
@code {
private string primaryKey { get; set; } = "editor1";
private ExampleModel exampleModel = new ExampleModel();
public class ExampleModel
{
[Required(ErrorMessage = "Insert a value")]
[StringLength(10, ErrorMessage = "Name is too long.")]
public string Name { get; set; }
public DateTime DateValue { get; set; }
}
public async Task EndEditEvent(EndEditEventArgs args, EditContext context)
{
if (args.Action == "Submit")
{
context.Validate();
await Task.Delay(500);
}
}
} |
This works perfectly
Thanks a lot