Skip to main content

Date Range

Two DateEdit extensions can be combined to implement a date range picker functionality. In this case, one editor is used to specify the start date, and another date editor specifies the end date. To link editors, set the DateRangeAttribute.StartDateEditFieldName property of the end-date editor to the field name of the start-date editor.

ASPxDateEdit_Range

public class DataRangePickerModel {
        [Display(Name = "Start Date")]
        public DateTime Start { get; set; }

        [Display(Name = "End Date")]
        [DateRange(StartDateEditFieldName = "Start", MinDayCount = 1, MaxDayCount = 30)]
        public DateTime End { get; set; }
}

You can customize the date range setting using the properties exposed by the DateRangeAttribute class. For instance, you can limit the date range using the following properties.

You can get the number of days selected within a range by using the client-side ASPxClientDateEdit.GetRangeDayCount method.

Important

The date range settings should be specified for the end-date editor.

See Also