Edit this page

Constraining Selection and Visible Dates

When certain dates are to be hidden or should not be selected by the user, the Calendar can hide or disable specific date ranges.

The following timeline shows how the selection and display ranges should relate to each other. All dates should fall between the MinDate and MaxDate, If DisplayDateStart/End are set, the SelectableDates range and all the selected dates must fall within it.

In the following example the Calendar has DisplayDateStart set to 6 Aug, while the SelectableDateStart is 14 Aug:

calendar display Selectable Date Start 1

The RadCalendar has several static methods (IsDisplayDateValid, IsDisplayDateStartValid, IsDisplayDateEndValid, IsSelectableDateStartValid, IsSelectableDateEndValid) that can check whether the desired values are valid for the given calendar, for example:

if (RadCalendar.IsDisplayDateValid(calendar, DateTime.Today))
{
    calendar.DisplayDate = DateTime.Today;
}
if (RadCalendar.IsDisplayDateStartValid(calendar, DateTime.Today.AddDays(-13)))
{
    calendar.DisplayDateStart = DateTime.Today.AddDays(-13);
}
if (RadCalendar.IsSelectableDateStartValid(calendar, DateTime.Today.AddDays(-5)))
{
    calendar.SelectableDateStart = DateTime.Today.AddDays(-5);
}

To add constraints for specific dates, use the TemplateSelector properties.