Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Creating Clickable Appointments-3 : Page 3


advertisement
Using vCalendar in a Web Application
Now that we know what a vcs file looks like we can plan to use it in our Web application. Consider a scenario in which we are listing events on our Web site based on data from a database. The pseudocode for this app would be as follows:

Open a connection to the database Obtain a list of events For each event Dump its details within a table row in HTML format Next event

This article does not deal with displaying events from a database. We have seen other 10-Minute Solutions that show you how to access data from a database and display it. We could therefore add a hyperlink to each event that allows a user to add the appointment to their calendar application.

Assume that we have a table containing events with the following structure:



Event_ID Event_Begin_Date Event_End_Date Event_Title Event_Location Event_Description

We can then use this code to dump the events in a list:

Do while not objRS.EOF Response.Write "<TR>" Response.Write "<TD>" & _ objRS("Event_Title") & "</TD>" Response.Write "<TD>" & _ FormatDateTime(objRS("Event_Begin_Date"), 2) & _ "- to - " & _ FormatDateTime(objRS("Event_End_Date"), 2) & "</TD>" Response.Write "<TD>" & _ objRS("Event_Location") & "</TD>" Response.Write "<TD>" & _ objRS("Event_Description") & "</TD>" Response.Write "</TR>" objRS.MoveNext Loop

This would produce a list of events with their titles, begin and end dates, location and description.

Title Begin Date - to - End Date Location Description

We can now add a link that allows users to automatically add the event to their appointments. To do this, add a hyperlink to a special ASP page that will return the text of the vcs file given a valid Event ID. In our example, we will be creating a new ASP page called "GetVCS.asp" that will return a vcs file back to the browser on demand.

We therefore modify the ASP code above to add a hyperlink to our "GetVCS.asp" page:

Do while not objRS.EOF Response.Write "<TR>" Response.Write "<TD>" & _ objRS("Event_Title") & "</TD>" Response.Write "<TD>" & _ FormatDateTime(objRS("Event_Begin_Date"), 2) & _ "- to - " & _ FormatDateTime(objRS("Event_End_Date"), 2) & "</TD>" Response.Write "<TD>" & _ objRS("Event_Location") & "</TD>" Response.Write "<TD>" & _ objRS("Event_Description") & "</TD>" Response.Write "<TD>" & _ "<A HREF=""getvcs.asp?id=" & _ objRS("Event_ID") & """>Add</A></TD>" Response.Write "</TR>" objRS.MoveNext Loop

This will produce the same listing as before, but for every event, there will now be a hyperlink to add the event to the user's appointments.

Title Begin Date - to - End Date Location Description Add

Clicking on the "Add" hyperlink will add the event details to the user's appointment program. Now let us see how the hyperlink generates a vCalendar on the fly.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date