DateTimePickerTemplated Control
Description
The DateTimePickerTemplated control is a templated version of the DateTimePicker control and is used to select a date and/or time using either a custom or predefined template. When a date is being selected, AJAX is used to automatically update the DropDownList for the day component to have the correct number of days for the month and year displayed and, if included in the selected day format, updates the day of the week. The date and/or time can be displayed in either order on one or two lines.
Example
Below are the available predefined templates for the DateTimePickerTemplated control and the server tags used to create them, along with a sample custom template:


DateTime2Line:

[SelectedDateTime]

TimeDate2Line:

[SelectedDateTime]

Date:
[SelectedDateTime]

Time:
[SelectedDateTime]

DateTime1Line:
[SelectedDateTime]

TimeDate1Line:
[SelectedDateTime]

Templated:
(Used regardless of Layout property if a template is supplied)
 : 
 /  / 

[SelectedDateTime]
Properties & Methods
DateTimePickerTemplatedThe DateTimePickerTemplated control is a templated version of the DateTimePicker control and is used to select a date and/or time using either a custom or predefined template
  • SelectedDateTime - The currently selected date and time
  • FirstYear - The first year displayed in the year DropDownList if the selected layout includes a date. If this value is greater than the year of SelectedDateTime it will be automatically adjusted
  • LastYear - The last year displayed in the year DropDownList if the selected layout includes a date. If this value is less than the year of SelectedDateTime it will be automatically adjusted
  • DayFormat - A member of the DayNameStyle enumeration specifying how and whether or not the day of the week should be displayed as part of the day DropDownList
  • MonthFormat - A member of the MonthNameStyle enumeration specifying the format for the month DropDownList
  • Layout - A member of the DTPLayout enumeration specifying the layout of the date and/or time DropDownLists
  • LayoutTemplate - The ITemplate in which the included DropDownLists and other controls are specified
DateTimePickerTemplated.DayNameStyle As ByteAn enumeration used to specify the format in which to display the day DropDownList
  • None - Displays the day as an integer
  • Full - Displays the day of the week followed by the day of the month
  • Short - Displays the day of the week abbreviation followed by the day of the month
  • FirstLetter - Displays the first letter of the day of the week followed by the day of the month
  • FirstTwoLetters - Displays the first two letters of the day of the week followed by the day of the month
DateTimePickerTemplated.MonthNameStyle As ByteAn enumeration used to specify the format in which to display the month DropDownList
  • Full - Displays the complete name of the month
  • Abbreviated - Displays the abbreviated name of the month
  • Numeric - Displays the month as a number from 1-12
DateTimePickerTemplated.DTPLayout As ByteAn enumeration used to specify the layout in which to display the date and/or time DropDownLists
  • DateTime2Line - Displays the date followed by a
    and the time
  • TimeDate2Line - Displays the time followed by a
    and the date
  • Date - Displays only the date
  • Time - Displays only the time
  • DateTime1Line - Displays the date followed by the time
  • TimeDate1Line - Displays the time followed by the date
Source Code
DateTimePickerTemplated.vb:

Remarks
When creating a LayoutTemplate, you must use the following IDs for the DropDownLists you include: ddlYear, ddlMonth, ddlDate, ddlHour, ddlMinute, ddlSecond, and ddlAMPM. If the ddlAMPM DropDownList is not included the 24-hour format will be used for the ddlHour DropDownList. Any other DropDownLists that are not included in the Template will be given the value of DateTime.MinValue when doing a postback. For example, if the ddlYear DropDownList is not included in the Template, the year used for SelectedDateTime will be DateTime.MinValue.Year.