Last Updated: 11 Apr 2022 11:51 by ADMIN
Release 3.2.0
Michael Yereniuk
Created on: 14 Jul 2021 13:10
Category: Form
Type: Bug Report
Validation does not trigger when the model comes from an async method

The Validation does not trigger when I load my model from an async method.



A workaround for the time being:

@inject HttpClient http
@using System.ComponentModel.DataAnnotations

<TelerikForm @ref="@EditForm" 
        <ValidationSummary />
        <FormItem Field="fact">
        <TelerikButton ButtonType="ButtonType.Submit" Primary="true">Apply</TelerikButton>

@code {
    public TelerikForm EditForm { get; set; }

    public CatFact TheCatFactTelerik = new CatFact();

    public EditContext editContext { get; set; }

    protected async override Task OnInitializedAsync()
        TheCatFactTelerik = await http.GetFromJsonAsync<CatFact>("");

    protected override async Task OnAfterRenderAsync(bool firstRender)

    public class CatFact
        [Required(ErrorMessage = "Required Error Text")]
        [MinLength(10, ErrorMessage = "Min Length 10")]
        public string fact { get; set; }
        public int length { get; set; }


1 comment
Paul Wood
Posted on: 17 Oct 2021 07:58

Surely this is a very common scenario that needs to be resolved sooner rather than later.

Also this workaround creates duplicate error messages for me which can be resolved by going:

protected override async Task OnAfterRenderAsync(bool firstRender)
if (firstRender) {
await Task.Run(() => editForm.EditContext.AddDataAnnotationsValidation());