Date Range in Blazor Calendar Component

26 Dec 20231 minute to read

A Blazor Calendar provides an option to select a date value within a specified range by defining the Min and Max properties. The Min date should always be lesser than the Max date.

  • If the value of Min or Max properties are changed through code behind, then update the Value property to be set within the specified range.

  • If the value is out of specified date range and less than the Min date, the Value property will be updated with the Min date. If the value is higher than the Max date, the Value property will be updated with the Max date.

The following code allows you to select a date within the range of 7th to 27th day in a month.

@using Syncfusion.Blazor.Calendars

<SfCalendar TValue="DateTime?" Min='@MinDate' Max='@MaxDate' Value='@DateValue'></SfCalendar>

    public DateTime MinDate {get;set;} = new DateTime(DateTime.Now.Year,DateTime.Now.Month,07);
    public DateTime MaxDate {get;set;} = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 27);
    public DateTime? DateValue {get;set;} = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 14);

DataRange in Blazor Calendar Component