DateRangePicker

in namespace DotVVM.BusinessPack.Controls

Usage & Scenarios

Lets the user select a start date and an end date, either in a drop-down editor or in calendars displayed directly on the page.

Sample 1: Selecting a travel period

Bind SelectedStartDate and SelectedEndDate to separate nullable DateTime properties. StartDatePlaceholder and EndDatePlaceholder identify the inputs before the user selects dates. Both the editor and the inline calendars below update the same period.

MinDate and MaxDate define the booking window. The inline view starts each week on Monday and shows week numbers; the Changed command counts edits in either view.

<bp:DateRangePicker SelectedStartDate="{value: Departure}" SelectedEndDate="{value: ReturnDate}"
                    StartDatePlaceholder="Departure" EndDatePlaceholder="Return"
                    MinDate="{value: Today}" MaxDate="{value: LastBookingDate}" AllowUnselect="true"
                    FormatString="dd MMM yyyy" Changed="{command: Changes = Changes + 1}" />

<bp:DateRangePicker ShowInline="true" FirstDayOfWeek="Monday" WeekNumberMode="FirstFourDayWeek"
                    MinDate="{value: Today}" MaxDate="{value: LastBookingDate}"
                    SelectedStartDate="{value: Departure}" SelectedEndDate="{value: ReturnDate}"
                    Changed="{command: Changes = Changes + 1}" />

<p>Changes: {{value: Changes}}</p>
using System;
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.DateRangePicker.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public DateTime Today => DateTime.Today;
        public DateTime LastBookingDate => Today.AddMonths(6);
        public int Changes { get; set; }
        public DateTime? Departure { get; set; }
        public DateTime? ReturnDate { get; set; }
    }
}

Properties

Name Type Description Notes Default Value
property icon AllowUnselect Boolean Gets or sets whether the selected value can be unselected. It is allowed by default.
attribute
inner element
static value
bindable
default
True
property icon AutoFocus Boolean Gets or sets whether the control should have focus when page loads or when a dialog is opened. The default value is false.
attribute
inner element
static value
bindable
default
False
property icon ConfirmIcon IconBase Gets or sets the icon to confirm selection and close popup dialog.
attribute
inner element
static value
bindable
default
null
property icon Enabled Boolean Gets or sets whether the control is enabled and can be modified.
attribute
inner element
static value
bindable
default
True
property icon EndDatePlaceholder String Gets or sets the text displayed when end date is not selected.
attribute
inner element
static value
bindable
default
null
property icon FirstDayOfWeek DayOfWeek? Gets or sets the first day of a week. Set the value to Monday if you want to display ISO 8601 weeks. The default value is based on the current culture.
attribute
inner element
static value
bindable
default
null
property icon FormatString String Gets or sets the format string that will be used to display the value.
attribute
inner element
static value
bindable
default
null
property icon MaxDate DateTime? Gets or sets the highest date that can be selected by user.
attribute
inner element
static value
bindable
default
null
property icon MinDate DateTime? Gets or sets the lowest date that can be selected by user.
attribute
inner element
static value
bindable
default
null
property icon NextIcon IconBase Gets or sets the icon displayed on the button navigating to next page.
attribute
inner element
static value
bindable
default
null
property icon Placeholder String Gets or sets the text displayed when value is not selected.
attribute
inner element
static value
bindable
default
null
property icon PrevIcon IconBase Gets or sets the icon displayed on the button navigating to previous page.
attribute
inner element
static value
bindable
default
null
property icon Restrictions IEnumerable<DateRestriction> Gets or sets a collection of rules specifying which date intervals can't be selected.
attribute
inner element
static value
bindable
default
null
property icon SelectedEndDate DateTime? Gets or sets the end date selected by user.
attribute
inner element
static value
bindable
default
null
property icon SelectedStartDate DateTime? Gets or sets the start date selected by user.
attribute
inner element
static value
bindable
default
null
property icon ShowInline Boolean Gets or sets whether the picker is displayed inline in page or as a drop-down editor.
attribute
inner element
static value
bindable
default
False
property icon StartDatePlaceholder String Gets or sets the text displayed when start date is not selected.
attribute
inner element
static value
bindable
default
null
property icon TabIndex Int32 Gets or sets the order in which the control is reachable in sequential keyboard navigation. The default value is 0 which means the document order.
attribute
inner element
static value
bindable
default
0
property icon ToggleIcon IconBase Gets or sets the icon displayed on the toggle button.
attribute
inner element
static value
bindable
default
null
property icon UnselectIcon IconBase Gets or sets the icon displayed on the unselect button.
attribute
inner element
static value
bindable
default
null
property icon UseFormatStringAsPlaceholder Boolean Gets or sets whether to use the FormatString as a placeholder when placeholder property is not set. It is enabled by default.
attribute
inner element
static value
bindable
default
True
property icon Visible Boolean
attribute
inner element
static value
bindable
default
True
property icon WeekNumberMode WeekNumberMode WeekNumberMode Gets or sets how are week numbers computed and whether to display them. The default value is Disabled.
attribute
inner element
static value
bindable
default
Disabled

Events

Name Type Description
event icon Changed Command Gets or sets the command triggered when the value is changed.

HTML produced by the control