I have recently (both personally and professionally) found it necessary to
implement a calendar within a web application. I roamed all of my favorite
web developer sites for a component that offered what I needed and did not
find anything very interesting.

The best example I found is at my second favorite ASP site (second only to 4 Guys,
which is of course my favorite), ASP 101.
They offer a great calendar app,
but it does not have very much functionality. My calendar needed to have current events
that were added and edited by registered users, so I took their code and make a few modifications.

Lets start by getting their code
and naming the page, calendar.asp. We are simply using their code as a generic starting point.

You then need a place to store your events. I created an access database called "users".
I then created a table within this database called "calendar". The calendar table has the
following fields:

Calendar

ID

Auto Number (And Primary Key)

Subject

Text

Message

Memo

Day

Number

Month

Number

Year

Number

AddedBy

Text

DateAdded

Date Time

All of the records are pretty self explanatory with the exception of the ID field.
We will use this later on to display the desired event.

Once the database is made, you then need to create your ASP pages. In this example,
we will use four pages; calendar.asp, display_event.asp, add_event.asp, and edit_event.asp.
You could probably get away with only two pages, but for ease-of-use, we will create four.

Lets start with the calendar.asp page.
As I mentioned earlier, we will be grabbing the bulk of the calendar code from
ASP 101. We need to then include the
ADO constants and connect to our databse (for more information on including ADOVBS.inc,
read How to use ADOVBS.inc):

We will then need to find the part of the code that writes out the days of the calendar and
insert the subjects of our database with a link to the display_event.asp page. This will give
the users something to click on to veiw the entire event.

If Not objRecordset.BOF Then
'--Move to the first record
objRecordset.MoveFirst
Do Until objRecordset.EOF
'--If the years match, then check the month and days--
If objRecordset.Fields("Year") = Year(dDate) Then
If objRecordset.Fields("Month") = Month(dDate) Then
If objRecordset.Fields("Day") = iCurrent Then
'--If everything matches the current day, then display
'the subject with the coresponding ID--
Response.Write("<br><font size=2><a href=" & _
Chr(34) & "display_event.asp?ID=" & _
objRecordset.Fields("ID") & Chr(34) & ">" & _
objRecordset.Fields("Subject") & _
"</a></font><br>")
End If
End If
End If
'--If nothing matches, move to the next record and
'start over again--
objRecordset.MoveNext
Loop
End If

We have now displayed the subject of the correct event with the event ID appended
on the URL as a query string (ex. display_event.asp?ID=10). When the user clicks
on the subject of the event, we pass the event ID on to the display_event.asp page.

Which brings us to the display event page. You need to first connect to the
database (same as above). You then need to get the event ID from the query string and
scroll through the database until we find the event:

EventToShow = CInt(Request.QueryString("ID"))
If Not objRecordset.EOF Then
objRecordset.MoveFirst
Do Until objRecordset.Fields("ID") = EventToShow
objRecordset.MoveNext
Loop
End If

We then want to correlate the displayed event with a session variable for editing and
display the event:

Do not forget to clean up your database connection after you are done with it:

objRecordset.Close
Set objRecordset = Nothing

The next two pages (edit_event.asp & add_event.asp) are very similar. The only exception is
that with the edit event, we want to display the excisting event within the form. As I
mentioned earlier, you could probably get away with combining these two pages. The one
thing you need to keep in mind is with the handling of the recorset. In the update page
we need to use objRecordset.Update, while in the add_event.asp page,
you will want to use objRecordset.AddNew.

In both cases, we need to connect to the database and input the data from the form
into the fields, similar to below:

There is obviously much more you can do with this example, but this will provide you with a
good starting point. You may want to only allow users to edit/delete events that THEY have
posted (this is where the AddedBy field comes into place). You may also want to insert a time
for the event. You could event color code the days that have events posted.