Displays a single month calendar. This calendar allows you to select a date and move it to the next month or last month.
ASP. NET
<Asp: calendar/>
Use the calendar control to display the calendar month on the webpage. This control allows you to select a date and move it to the next month or last month. The calendar control supports all the system. Globalization. Calendar types in the system. Globalization namespace. In addition to the Gregorian calendar, this includes calendars that use different year and month systems, such as the hjsiri calendar.
You can set the selectionmode attribute to specify whether the calendar ar control allows you to select a single day, week, or whole month.
By default, this control displays the header of each day in the month, the day in the week, the title with the month name and year, the link used to select each day in the month, and the link used to move to the next month and last month. You can customize the appearance of the calendar control by setting the style attributes of different parts of the control. The following table lists the style attributes of different parts of the specified control.
Attribute description
Dayheaderstyle
Specify a style for each day of a week.
Daystyle
Specify a style for the date in the displayed month.
Nextprevstyle
Specify a style for the Navigation Control in the title section.
Othermonthdaystyle
Specify a style for the date that is not currently displayed in the month.
Selecteddaystyle
Specify a style for the selected date in the calendar.
Selectorstyle
Specify a style for the week and month date columns.
Titlestyle
Specify a style for the title.
Todaydaystyle
Specify a style for today's date.
Weekenddaystyle
Specify a style for the weekend date.
You can also display or hide different parts of the control. The following table lists the attributes that control the display or hide parts.
Showdayheader
Show or hide the parts of each day of a week.
Showgridlines
Displays or hides the gridlines between days of a month.
Shownextprevmonth
Display or hide the navigation controls pointing to the next month or last month.
Showtitle
Show or hide the TITLE section.
Although the calendar control does not support binding to a data source, you can modify the content and format settings of each date cell. Before the calendar control is displayed on the webpage, it creates and assembles components that constitute the control. The dayrender event is triggered when each date cell in the calendar ar control is created. Handle events in dayrender eventProgramProvided inCodeYou can control the content and format settings when creating a date cell.
The calendar control presents ecmascript (jscript, JavaScript) to the client browser. The client browser must enable ecmascript for the control to work properly.
The following code example shows how to create a calendar control on a webpage.
<% @ Page Language = "C #" autoeventwireup = "true" %>
doctype HTML Public "-// W3C // dtd xhtml 1.0 transitional // en "
" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
HTML xmlns =" http://www.w3.org/1999/xhtml " >
head >
title > Asp. net example title >
head >
<Body>
form id =" form1 " runat =" server " >
Asp: calendar id =" calendar1 " runat =" server " >
othermonthdaystyle forecolor =" lightgray " >
</Othermonthdaystyle>
titlestyle backcolor =" blue "
forecolor =" white " >
</Titlestyle>
daystyle backcolor =" gray " >
</Daystyle>
selecteddaystyle backcolor =" lightgray "
font-bold =" true " >
</Selecteddaystyle>
</ASP: Calendar>
</Form>
body >
</Html>
Running result: