Export (0) Print
Expand All

Calendar control

The Calendar control displays a calendar through which users can navigate to any day in any year. When the ASP.NET page runs, the Calendar control is rendered as an HTML table. Therefore, a number of the control's properties pertain to various aspects of table formatting. A few of these properties are not fully supported in some older browsers, so not all of the formatting features will be available in those browsers.

The Calendar control is a fairly complex control and has a lot of programming and formatting options. For details about using the Calendar control, see Calendar Web Server Control (Visual Studio) in the MSDN library.

To add a Calendar control to a page

  • Drag the Calendar control from the Toolbox task pane to your page.

To apply basic formatting schemes to the Calendar control

  • In Design view, right-click the Calendar control, and then click Show Common Control Tasks.

Cc295478.alert_tip(en-us,Expression.10).gifTip:

You can also click the Calendar control in Design view, click the arrow Cc295478.56557a2a-a4ef-4c47-906b-f64b8d530387(en-us,Expression.10).png in the upper-right corner to show the Common Calendar Tasks menu. Click the arrow again to hide the menu.

  1. On the Common Calendar Tasks menu, click AutoFormat.

  2. In the AutoFormat dialog box, select one of the schemes in the Select a scheme list. The effect of the scheme on your Calendar control is displayed in the Preview area.

  3. Click OK to apply the formatting scheme and close the dialog, or Apply to apply the formatting scheme without closing the dialog.

To set other properties that determine the Calendar's appearance and behavior, use the Tag Properties task pane.

To use the Tag Properties task pane to set Calendar properties

  1. Right-click the Calendar control in Design view and click Properties in the shortcut menu.

  2. Type property values, or select them from dropdown lists where they are available.

For a full description of all Calendar control properties, see Calendar Properties in the MSDN library.

You can set properties to specify the way users can interact with the Calendar.

Common Calendar functionality properties

Properties

Description

SelectedDate

Causes a specific date to be highlighted in the control.

ShowNextPrevMonth

Enables or disables user month navigation. By default, the calendar displays the month containing today's date. Users can move from month to month in the Calendar control by clicking month navigation links in the title bar of the calendar. If the property is false, the control does not display the controls in the title that allow a user to move between months.

SelectionMode

Set this property to one of the values defined in the SelectionMode enumeration: Day, DayWeek, or DayWeekMonth to specify what a user can select. To disable all date selection, set the property to None. To allow the user to select a date, the calendar is displayed with links. Individual days contain a link with the date number. If you set the calendar to allow users to select a week or the whole month, an extra column with selection links is added to the left of the calendar.

VisibleDate

This date determines which month appears in the calendar. The user can move from month to month on the calendar, thereby changing the visible date without affecting today's date. You can navigate between months by setting the visible date programmatically.

Because the Calendar control is a complex control made up of many individual elements, it offers you a wide variety of options for customizing its appearance.

The Calendar control establishes a default look for the calendar on the page, but you can change the calendar's overall appearance. If you set appearance properties for individual calendar elements, such as today's date, the selected date, and so on, the individual settings are based on the default settings you make for the calendar as a whole.

Common Calendar Appearance Properties

Properties

Description

Font, ForeColor, BackColor

Change the font, text and background color.

Height, Width

Change overall control size.

NextMonthText, PrevMonthText, NextPrevFormat, NextPrevStyle

Changes the appearance of the month-navigation hyperlinks.

CellPadding, CellSpacing

Change margins and spacing around individual days.

FirstDayOfWeek

Specify which day starts the week (default is Sunday).

DayStyle

Set the style for days of the current month. Weekends, today, and the selected day can have different styles.

DayHeaderStyle

Set the style for the row above the calendar where the names of the days appear.

NextPrevStyle

Set the style for the sections at the left and right ends of the title bar where the month-navigation LinkButtons are.

OtherMonthDayStyle

Set the style for the days from the previous and next month that appear on the current month view.

SelectedDayStyle

Set the style for the day selected by the user.

SelectorStyle

Set the style for the column to the left containing links for selecting a week or the whole month.

TitleStyle

Set the style for the title bar at the top of the calendar containing the month name and month navigation links. If NextPrevStyle is set, it overrides the extreme ends of the title bar.

TodayDayStyle

Set the style for today's date.

WeekendDayStyle

Set the style for weekend days.

For more information about the Calendar control, see Calendar Web Server Control Overview in the MSDN library.

Community Additions

ADD
Show:
© 2014 Microsoft