ASP Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.11

hyBook - A Simple Guestbook Application

Part:   1  2  3  4  5  6  7  8  9  10  11  12  13 

ASP Tutorials - Herong's Tutorial Notes © Dr. Herong Yang

hyBook - Guestbook Application

Using MS Access Databases

ActiveX Data Object (ADO)

Controlling Response Header Lines

Microsoft Scripting Runtime DLL

Using Cookies

ASP Sessions

ASP Objects

Microsoft Script Debugger

Internet Information Services (IIS)

... Table of Contents

(Continued from previous part...)

Page Layout Templates

In order for hyBook to be integrated into different into different Web site, where each of them may different page layout, I have designed hyBook page to be based on template include files. Here is how this design works.

1. Each ASP page will have a template include file inserted at the beginning.

2. The template include file provides code to control the page layout.

3. The page layout should have blank blocks where some ASP function calls will be placed.

4. Each ASP page should only implement those ASP functions called by the template.

For example, the following is a template include file in my hyBook demonstration package:

<%
   opening
%>
<?xml version="1.0"?>
<html><head>
<title>hyBook - Demo</title>
<meta name="description" content="Demonstration page of hyBook 
- A simple guest book script"/> 
<meta name="keywords" content="hyBook, Guestbook, ASP">
<link rel="stylesheet" type="text/css" href="hyBook.css"/>
</head><body>

<center>
<%
   outputHeader
%>
<!-- Other HTML or ASP codes -->
<%
   outputBody
%>
<!-- Other HTML or ASP codes -->
<%
   outputFooter
%>
<p>Powered by <a href=http://www.herongyang.com/hyBook/>hyBook</a></p>
</center>

</body></html>
<%
   closing
%>

Note that there are 5 ASP function calls placed in this template:

  • "opening" - Giving the ASP page a chance to do initialization work, like establishing database connection, and checking input data in the HTTP request.
  • "opening" - Giving the ASP page a chance to do closing up work, like closing database connection.
  • "outputHeader" - Allowing the ASP page to generate HTML code designed as the header block.
  • "outputBody" - Allowing the ASP page to generate HTML code designed as the body block.
  • "outputFooter" - Allowing the ASP page to generate HTML code designed as the footer block.

What's goes into the header block, the body block, and the footer block is up to the author of the page. Of course, if you don't use any of those blocks, just implement an empty function in the ASP page.

Also note that a CSS file, hyBook.css, is designed in hyBook to allow you control the appearance of individual HTML elements.

Guestbook Main Page

Once we understand the database, configuration, and template, we are ready to look at the guestbook main page, default.asp. The main objectives of default.asp are:

1. Takes a topic id from the query string so that it can be invoked for any given topics defined in the database.

2. Displays then content of the given topic.

3. Displays all existing comments associated with the given topic.

4. Offers a blank form to allow visitors to enter their comment for the given topic.

5. Stores new comment into database, when a visitor submits the form.

(Continued on next part...)

Part:   1  2  3  4  5  6  7  8  9  10  11  12  13 

Dr. Herong Yang, updated in 2005
ASP Tutorials - Herong's Tutorial Notes - hyBook - A Simple Guestbook Application