TimePicker

in namespace DotVVM.BusinessPack.Controls

Renders a selector allowing users to select a time.

Usage & Scenarios

Renders a text field that allows the user to enter or select time.

Sample 1: Basic Usage

The SelectedTime property represents a Time value with a time selected in the control.

<bp:TimePicker SelectedTime="{value: SelectedTime}" />

<p>Selected time: <dot:Literal Text="{value: SelectedTime}" FormatString="g" /></p>
using System;
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.TimePicker.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public DateTime SelectedTime { get; set; } = DateTime.Now;
    }
}

Sample 2: Selection Bounds

You can use the MinTime and MaxTime properties to specify the minimum and maximum values for the selection.

<bp:TimePicker SelectedTime="{value: SelectedTime}"
               MinTime="{value: MinimumTime}"
               MaxTime="{value: MaximumTime}" />

<p>Selected time: <dot:Literal Text="{value: SelectedTime}" FormatString="g" /></p>
using System;
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.TimePicker.sample2
{
    public class ViewModel : DotvvmViewModelBase
    {
        public DateTime SelectedTime { get; set; } = DateTime.Now;
        public DateTime MinimumTime { get; set; } = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 
            7, 30, 0);
        public DateTime MaximumTime { get; set; } = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 
            19, 30, 0);
    }
}

Sample 3: Restrictions

If you require more granular control over what dates can be selected, you can use the Restrictions property.

  • TimeRangeRestriction - Allows to disable selection of a specific time range. You just need to set the StartTime and EndTime properties, where the StartTime represents inclusive start of the restriction and EndTime represents end of the restriction. Date part of the DateTime values is ignored so any date can be provided.
<bp:TimePicker SelectedTime="{value: SelectedTime}"
               Restrictions="{value: Restrictions}" />

<p>Selected time: <dot:Literal Text="{value: SelectedTime}" FormatString="g" /></p>
using System;
using System.Collections.Generic;
using DotVVM.BusinessPack.Controls;
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.TimePicker.sample3
{
    public class ViewModel : DotvvmViewModelBase
    {
        public DateTime SelectedTime { get; set; } = DateTime.Now;

        public List<TimeRestriction> Restrictions { get; set; } = new List<TimeRestriction>()
        {
            //This will prevent selection of any time between 11:45:00 to 13:14:59
            new TimeRangeRestriction() {
                StartTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day,
                    11, 45, 0),
                EndTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day,
                    13, 15, 0)
            },
            //This will prevent selection of any time between 16:30:00 to 17:29:59
            new TimeRangeRestriction() {
                StartTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day,
                    16, 30, 0),
                EndTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day,
                    17, 30, 0)
            }
        };
    }
}

Sample 4: Inline

The ShowInline property toggle whether the TimePicker is displayed inline in page or as a drop-down editor.

<bp:TimePicker SelectedTime="{value: SelectedTime}"
               ShowInline />

<p>Selected time: <dot:Literal Text="{value: SelectedTime}" FormatString="g" /></p>
using System;
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.TimePicker.sample4
{
    public class ViewModel : DotvvmViewModelBase
    {
        public DateTime SelectedTime { get; set; } = DateTime.Now;
    }
}

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 AmPmDesignatorText String Gets or sets the text displayed above a dial used to select AM / PM designator. The default value is "AM/PM".
attribute
inner element
static value
bindable
default
AM/PM
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 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 HourText String Gets or sets the text displayed above a dial used to select hour. The default value is "Hour".
attribute
inner element
static value
bindable
default
Hour
property icon MaxTime DateTime? Gets or sets the highest time that can be selected by user.
attribute
inner element
static value
bindable
default
null
property icon MinTime DateTime? Gets or sets the lowest time that can be selected by user.
attribute
inner element
static value
bindable
default
null
property icon MinuteText String Gets or sets the text displayed above a dial used to select minute. The default value is "Minute".
attribute
inner element
static value
bindable
default
Minute
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<TimeRestriction> Gets or sets a collection of rules specifying which time intervals can't be selected.
attribute
inner element
static value
bindable
default
null
property icon SecondText String Gets or sets the text displayed above a dial used to select second. The default value is "Second".
attribute
inner element
static value
bindable
default
Second
property icon SelectedTime DateTime? Gets or sets the time 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 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

Events

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

HTML produced by the control