Home » ASP.Net Calender

ASP.NET Web Forms Calendar

It is used to display selectable date in a calendar. It also shows data associated with specific date. This control displays a calendar through which users can move to any day in any year.

We can also set Selected Date property that shows specified date in the calendar.

To create Calendar we can drag it from the toolbox of visual studio.

This is a server side control and ASP.NET provides own tag to create it. The example is given below.

Server renders it as the HTML control and produces the following code to the browser.

This control has its own properties that are tabled below.

Property Description
AccessKey It is used to set keyboard shortcut for the control.
TabIndex The tab order of the control.
BackColor It is used to set background color of the control.
BorderColor It is used to set border color of the control.
BorderWidth It is used to set width of border of the control.
Font It is used to set font for the control text.
ForeColor It is used to set color of the control text.
Text It is used to set text to be shown for the control.
ToolTip It displays the text when mouse is over the control.
Visible To set visibility of control on the form.
Height It is used to set height of the control.
Width It is used to set width of the control.
NextMonth Text It is used to set text for the next month button.
TitleFormat It sets format for month title in header.
DayHeaderStyle It is used to set style for the day header row.
DayStyle It is used to apply style to days.
NextPrevStyle It is used to apply style to the month navigation buttons.

Calendar Property Window

ASP Calendar 1

Example

In this example, we are implementing calendar and displaying user selected date to the web page.

// WebControls.aspx

Code Behind

// WebControls.aspx.cs

Output:

This view shows calendar to the browser.

ASP Calendar 2

It shows date selected by the user at the web page. A screenshot is attached below.

ASP Calendar 3

Next TopicASP.NET CheckBox

You may also like