Demonstrates the commands through keystroke shortcuts, help button and context menu
The Calendar has the following commands:
- Today - Sets today's date.
- Special - Sets the date assigned to the SpecialDate property.
- Clear - Removes selections.
- Show Selection - Changes the month viewed to the month with the selected date.
- Apply - Applies the selection to another control (like the DateTextBox).
- Close - Closes a popup calendar without applying the selection.
- Next Month - Advances one month
- Previous Month - Goes back on month
- Next Year - Advances one year
- Previous Year - Goes back one year
- MonthYearPicker - Pops up the MonthYearPicker
The user can access these commands in several ways:
- Keyboard shortcut - Type a special keystroke to invoke the command.
- Help button - Displays a toggle button to display a menu of commands.
Use the HelpCommand.ShowField property to activate the button.
Generally set its value to 'RecommendedRow'.
- Context menu - Right click in the textbox to display a menu of commands. It is the same menu as
on the Help button. It is enabled by default. To disable it, set ContextMenu.Activate to false.
- Buttons on the Calendar - These are covered in the topics
"Month and Year" buttons and
"Footer commands".
The following properties host the features of each command:
TodayCommand,
SpecialCommand,
ClearCommand,
ShowSelectionCommand,
ApplyCommand,
CloseCommand,
NextMonthCommand,
PreviousMonthCommand,
NextYearCommand,
PreviousYearCommand, and
MonthYearCommandAndLabel
These Command properties can be customized in several ways:
- To rename a command, assign the name in the CommandName property.
- To change the keyboard shortcut, assign the keystroke combination in the MenuKeys property.
Only one keystroke must be hit to execute a command. However, you can define multiple keystrokes, each to run the same command. This allows for you to assign several familiar keystrokes for the command. For example, the Today command can be both "T" and "D". To enter multiple keystrokes, separate each with a space. For example, TodayCommandKeys = “T D”.
The Calendar allows commands to be assigned to most keys except the digits and the date separator. You can also assign these terms: ENTER, ESC, SPACE, PAGEUP, PAGEDOWN, HOME, END, F1..F12, DELETE, LEFT, RIGHT, UP, and DOWN. If you set this property to an empty string, no keystroke will support that command. However, the context menu will still offer this command.
These commands also support the Control key modifier. Put “CTRL+” before the character. For example, “CTRL+T”.
- To remove a command, set its ShowCommandInMenu property to false.
The keyboard short cut is still active until you set MenuKeys to "".
Controls
Adding the Help button with HelpCommand.ShowField="RecommendedRow"
The ContextMenu is available too as its active by default.
27 | 28 | 29 | 30 | 31 | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
Removing the ContextMenu with ContextMenu.Activate="false"
Right click in the textbox. The browser's standard context menu appears.
27 | 28 | 29 | 30 | 31 | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
Changing a command name and its keystroke with CommandName and MenuKeys properties
This example renames the MonthYearPicker command to "Specify a month"
and allows both "M" and Control D to display the calendar.
27 | 28 | 29 | 30 | 31 | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
Removing commands with the ShowCommandInMenu property
This example removes the MonthYearPicker command.
27 | 28 | 29 | 30 | 31 | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
Source Code (C#)
<h2>Adding the Help button with HelpCommand.ShowField="RecommendedRow"</h2>
The ContextMenu is available too as its active by default.<br/><br/>
<des:Calendar ID="DateTextBox1" runat="server">
<HelpCommand ShowField="RecommendedRow" />
</des:Calendar>
<br/><br/>
<h2>Removing the ContextMenu with ContextMenu.Activate="false"</h2>
Right click in the textbox. The browser's standard context menu appears.<br/><br/>
<des:Calendar ID="DateTextBox2" runat="server">
<HelpCommand ShowField="RecommendedRow" />
<ContextMenu Activate="false" />
</des:Calendar>
<br/><br/>
<h2>Changing a command name and its keystroke with CommandName and MenuKeys properties</h2>
This example renames the MonthYearPicker command to "Specify a month"
and allows both "M" and Control D to display the calendar.<br/><br/>
<des:Calendar ID="DateTextBox3" runat="server" >
<HelpCommand ShowField="RecommendedRow" />
<MonthYearCommandAndLabel CommandName="Specify a month" MenuKeys="M CTRL+D" />
<ContextMenu SharedGroup="DateTextBox3" />
</des:Calendar>
<br/><br/>
<h2>Removing commands with the ShowCommandInMenu property</h2>
This example removes the MonthYearPicker command.<br/><br/>
<des:Calendar ID="DateTextBox4" runat="server" >
<HelpCommand ShowField="RecommendedRow" />
<MonthYearCommandAndLabel ShowCommandInMenu="No" />
<ContextMenu SharedGroup="DateTextBox4" />
</des:Calendar>
<br/><br/>