Download the Code [^] -
Updated 4/13/2002
This is a C# project for VS.Net.
I needed a web based even calendar and thanks to the new .Net Calendar
Control, the rest was easy. What I ended up with was a nice little event based
calendar. If you select a date with a scheduled event, a Repeater Control
appears below the calendar with event specifics for the day selected. The code
was cut from the page on my site (http://dn.yyyz.net/DnYzCalendar.aspx [^])
so there is some extra code that may not be used in this example. A second
page located at
http://dn.yyyz.net/DnYzCalendarAdmin.aspx [^] and not covered in this article
or currently available for distribution is used to add event times and dates.
| Files Included |
Description of Included File |
| CaEvents.htm |
This Page |
| Calendar.aspx |
The .aspx page that holds the calendar and other
controls |
| Calendar.aspx.cs |
The .aspx.cs page with the calendar code and logic
|
| CaEvents.css |
Contains a few styles used in the pages |
| CaEvents.cs |
A Class based on the database table. Most of the
functions are not used in this example but are used in the Set Events
page which is not covered in this article. |
| CaEvents.sql |
The SQL statement that will create the events table in
SQL 2000 |
| Web.Config |
Make sure that you change the connection
string in appSettings |
All the calendar formatting and functionality occurs in the
yZCalendar.aspx.cs file. The following is a list of functions included in the
code behind page and a brief description of each.
| Name |
Description of Functions in Calendar.aspx.cs |
| SetControls |
Sets the initial values used in the Year/Month
textboxes. |
| fmtCalendar |
Adds formatting to the calendar control. I prefer to
format in the .aspx.cs file rather than the .aspx file. |
| MonthLyEvents |
Get the events from the database. We get all events
for the month, plus 10 days on each side of the month. The calendar
control uses a 7x6 grid and it is possible that there could be 8 or 9
days before or after the actual month being presented. We couldn't find
a property or method to get the actual starting and ending days so we
merely get an additional 10 days of events to insure all dates get
presented. |
| SetDbDates |
Sets the 1st and last date that we get from the
database. |
| btnJump_Click |
The event that handles the 'Time Travel' button. |
| C1DateSelected |
The event handler when a date is clicked on. |
| C1MonthRender |
The event called when the month is changed. We call
the SetDbDates function to get the beginning and ending days to use in
the database query. |
| C1DayRender |
Renders each day of the calendar. This is where any
events are added to the calendar. The CaEvents Class contains a 15
character description that is add to the appropriate date. |
| BindRepeater |
Binds the repeater control to list any
events scheduled on a selected day. |
Top 