Home   |   QuickStart Welcome   |   ASP.NET   |   Web Services   |   How Do I...?   
  |   I want my samples in...      

ASP.NET 2.0 Quickstart Tutorials

Calendar

The Calendar control displays a month calendar from which users can select dates. The following sample illustrates using a simple Calendar control.

VB Calendar1.aspx
Run Sample View Source

Date Selection Modes

Calendar supports four date selection modes, as described in the following table.

Mode Description
Day User can select any single day.
DayWeek User can select a single day, or an entire week.
DayWeekMonth User can select a single day, an entire week, or the entire visible month.
None Date selection is disabled.


The following sample demonstrates mode selection with a Calendar control.

VB Calendar2.aspx
Run Sample View Source

Selection Link Graphics

The Calendar control can use either text or graphics for its selection links. The following sample shows how to use graphics to create a better-looking calendar.

VB Calendar3.aspx
Run Sample View Source

Selection Link Text

The Calendar control can also use text labels for week or month selection, as shown in the following example.

VB Calendar4.aspx
Run Sample View Source

Adding Custom Content to Calendar

You can make appointment-style calendars by adding content in the OnDayRender event. Two of the arguments for OnDayRender are the Day that is being rendered and its Cell object. Custom text can be added to the cell for a particular day by adding it as a LiteralControl to the Cell object's Controls collection, as shown in the following example.

		
string Hol = GetHoliday(Day.Date);

if (Hol != string.Empty) Cells.Controls.Add(new LiteralControl("<br>" + Hol));
C#


VB Calendar5.aspx
Run Sample View Source