New to Telerik UI for Blazor? Download free 30-day trial

Stop the cascading EditContext for a specific field in the Form


Product Form for Blazor


I would like to stop the cascading EditContext for a specific editor in my Form. The Editor should still be in the Form, but should not be validated. This would also allow me to not provide a ValueExpression.


To stop the cascading EditContext for a specific editor in the TelerikForm you should use the Template and wrap the custom editor in a <CascadingValue> tag. In the Value attribute of the CascadingValue you should reset the EditContext.

@* Stop the cascading EditContext for the Edit the DoB checkbox. *@ 

@using System.ComponentModel.DataAnnotations

<TelerikForm Model="@person">
                <CascadingValue Value="@((EditContext?)null)">
                    <label for="enable-datepicker">Edit the DoB</label>
                    <TelerikCheckBox Value="@Enabled" OnChange="@(v => OnChange((bool)v))" Id="enable-datepicker"></TelerikCheckBox>
        <FormItem Field="@nameof(Person.Id)" Enabled="false" LabelText="Id"></FormItem>
        <FormItem Field="@nameof(Person.FirstName)" LabelText="First name" Hint="Enter your first name"></FormItem>
        <FormItem Field="@nameof(Person.LastName)" LabelText="Last name" Hint="Enter your last name" ColSpan="2"></FormItem>
        <FormItem Field="@nameof(Person.DOB)" LabelText="Date of Birth" Hint="Enter your Date of Birth" Enabled="@Enabled"></FormItem>

@code {
    public Person person = new Person();

    private bool Enabled { get; set; }

    private void OnChange(bool value)
        Enabled = value;

    public class Person
        public int Id { get; set; } = 10;
        public string FirstName { get; set; } = "John";
        public string LastName { get; set; } = "Doe";
        public DateTime DOB { get; set; } = DateTime.Today.AddYears(-20);
In this article