Trigger form validation manually RadzenTemplateForm

Hi,
I want to fetch data from the database and populate it into forms when the page loads. Afterward, I want to immediately execute validation so that errors are displayed in red for correction.

<RadzenTemplateForm @ref=xForm TItem="xModel" Data=@SelectedX Submit="@Soumettre" InvalidSubmit="@OnInvalid">
     <ChildContent Context="formContext">
         <DataAnnotationsValidator />

if (!xForm.IsValid) : Use this instruction to ensure that form is valid but i want in
protected override async Task OnInitializedAsync() Run validation.

Thanks.

EditContext.Validate() can do that:
https://forum.radzen.com/search?context=topic&context_id=15226&q=EditContext.Validate&skip_context=true

1 Like

Thanks it is good :

protected override async Task OnAfterRenderAsync(bool firstRender)
{
    if (xForm != null)
    {
        xForm.EditContext.Validate();
    }
}