HOME

ASP.NET Tutorial
ASP.NET HOME
ASP.NET Intro
ASP.NET vs ASP
ASP.NET Install
ASP.NET Pages
ASP.NET Controls
ASP.NET Events

References
HTML Controls
Web Controls
Validation Controls
Download XMLSpy here
Please visit our sponsors !

Calendar Control

Back

Definition and Usage

The Calendar control is used to display a calendar in the browser.

This control displays a one-month calendar that allows the user to select dates and move to the next and previous months.


Properties

Property Description
CellPadding The space, in pixels, between the cell walls and contents
CellSpacing The space, in pixels, between cells
DayHeaderStyle The style for displaying the names of the days
DayNameFormat The format for displaying the names of the days. Can take one of the following values:
  • FirstLetter
  • FirstTwoLetters
  • Full
  • Short
DayStyle The style for displaying days
FirstDayOfWeek What should be the first day of week. Can take one of the following values:
  • Default
  • Monday
  • Tuesday
  • Wednesday
  • Thursday
  • Friday
  • Saturday
  • Sunday
id A unique id for the control
NextMonthText The text displayed for the next month link
NextPrevFormat The format of the next and previous month links. Can take one of the following values:
  • ShortMonth
  • FullMonth
  • CustomText
NextPrevStyle The style for displaying next and previous month links
OnDayRender The name of the function to be executed when when each day cell is created
OnSelectionChanged The name of the function to be executed when the user selects a day, week, or month
OnVisibleMonthChanged The name of the function to be executed when the user navigates to a different month
OtherMonthDayStyle The style for displaying days that are not in the current month
PrevMonthText The text displayed for the previous month link
runat Specifies that the control is a server control.  Must be set to "server"
SelectedDate The selected date
SelectedDates The selected dates
SelectedDayStyle The style for selected days
SelectionMode How a user is allowed to select dates. Can take one of the following values:
  • None
  • Day
  • DayWeek
  • DayWeekMonth
SelectMonthText The text displayed for the month selection link
SelectorStyle The style for the month and weeks selection links
SelectWeekText The text displayed for the week selection link
ShowDayHeader A Boolean value that specifies whether the days of the week header should be shown
ShowGridLines A Boolean value that specifies whether the grid lines between days should be shown
ShowNextPrevMonth A Boolean value that specifies whether the next and previous month links should be shown
ShowTitle A Boolean value that specifies whether the title of the calendar should be shown
TitleFormat The format for the title of the calendar. Can take one of the following values:
  • Month
  • MonthYear
TitleStyle The style of the title of the calendar
TodayDayStyle The style for today's date
TodaysDate Today's date
VisibleDate The date that specifies the month that is currently visible in the calendar
WeekendDayStyle The style for weekends

Example 1

In the following example we declare a Calendar control in its simplest use, in an .aspx file:

<html>
<body>
<form runat="server">
<asp:Calendar id="Calendar1" runat="server" />
</form>
</body>
</html>

Example 2

In the following example we declare a Calendar control in an .aspx file. The days are displayed with full names, the weekends are displayed in blue on a yellow background, and the current date is displayed with a red background:

<html>
<body>
<form runat="server">
<asp:Calendar id="Calendar2" DayNameFormat="Full" runat="server">
  <WeekendDayStyle BackColor="Yellow" ForeColor="Blue" />
  <TodayDayStyle BackColor="Red" />
</asp:Calendar>
</form>
</body>
</html>

Example 3

In the following example we declare a Calendar control in an .aspx file. The days are displayed with full names, the user may select a day, a week, or the whole month, and the selected day/week/month is displayed with a grey background color:

<html>
<body>
<form runat="server">
<asp:Calendar id="Calendar3" DayNameFormat="Full" runat="server"
SelectionMode="DayWeekMonth" SelectMonthText="&lt;*&gt;"
SelectWeekText="-&gt;"/>
  <SelectorStyle BackColor="LightGray" />
</asp:Calendar>
</form>
</body>
</html>


Back

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

IISCart
ASP Ecommerce & Shopping Cart


Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search