Most Web applications are simply several pages linked together. If the viewer has a question or requires help, a simple hyperlink to FAQ does the trick. But some applications require incorporating a more complicated help system into the existing Web application.
There are many different types of Internet Web application help systems. By far, the most popular method is to simply create one page with every help item for every page on the Web site. Basically, everything is on the one large page. Users click on the help button or hyperlink and they receive everything they could ever want about your site.
The problem is that they simply had a quick question and thought the help option would generate a quick and simple answer. Yet they entered a world where they must now click and scroll through massive amounts of data in hopes of finding the answer to the now forgotten question. Worse yet, they may have bypassed your site altogether, since they could not get their answer quickly or were simply annoyed at the effort needed to find some help.
I have seen this type of application grow into a web of hyperlinks and HTML pages. And soon the programmers themselves are confused with the interlinks of all the help pages.
The other more advanced method is a full-blown help application. Click on the help icon and you dive into an application system for the help option. You obtain the help required for that page and then some. You could search the entire help directory or choose another item, which had nothing to do with the initiating page. This type of application is more in common with online books. This kind of help application is more thorough because it covers the entire application, including other aspects such as customization or installation of client components.
A third method lies between the above two in functionality. This is a really quick and easy design solution where each page on your site has its own separate help page invoked by one easy statement, as follows:
<a href="help.asp">Help</a>
That is it! Every single Web page requiring help would include this simple hyperlink. Users can simply click on the hyperlink and all help pertaining to the specific page is displayed. To return to the initiating page, the user simply clicks on a return button on the help page, and the flow is returned to the original page. This entails doing nothing more tothe primary Web application. The help system is completely self contained.The Process
The following graphic explains the overall flow of the application design:
Application Design
A database contains one row in a table for every calling Web page. Each row has all the required text to be displayed for the application.
A strong feature of this design is the default help page. If a new Web page is added to the application or the page name changes, thus being out of sync with the database table row, this help system will default to an “under construction” message for that specific page. So a built-in fail-safe is incorporated into this help application.
Also, if the help text changes, only an update to the table row for the specific page’s entry is required. There are no pages to change.
The Invoking Page
Each Web page requiring help on your Web site must contains a hyperlink to an ASP page called help.asp, as follows:
<a href="help.asp">Help</a>
This hyperlink has minimal impact on the initiating Web application, which can be ASP or regular HTML.
The ASP Page
The help.asp page is executed on an IIS 4.0 host server.
The same concept could be used for any other WWW Server, such as Apache. This can be accomplished with only several minor changes to just a couple of parameters, such as server variables used. Instead of Visual BASIC (VB) script, JavaScript can be used to connect to the data source. And, instead of ASP pages, Common Gateway Interface (CGI) or Perl script pages could be used to return result sets to the pages requiring help.
The Referring Page
The help.asp page determines the invoking page by inquiring on the server variable HTTP_REFERER with the following VB script code:
The help.asp page determines the invoking page by inquiring on the server variable HTTP_REFERER with the following VB script code:
<% @LANGUAGE="VBSCRIPT" %>
<%
'---- Find the start of the name of the invoking page.
'---- Some standardization of page names will help here.
WhereIsLastSlash = InStrRev(Request.ServerVariables("HTTP_REFERER"),"/")
WhoNeedsHelp = Mid(Request.ServerVariables("HTTP_REFERER"), _
(WhereIsLastSlash + 1), _
len(Request.ServerVariables("HTTP_REFERER")) - WhereIsLastSlash)
%>
First, part of this code will determine where in the HTTP_REFERER variable is the last slash, and then this information will be used to extract the referring page name. This step is accomplished by using InStrRev, which does the same thing as InStr, but will start searching for the requested string from right to left (in other words, in reverse order).
The WhoNeedsHelp variable will contain the referring page, which called the help.asp page.
The Database Design
The simple part is that all the help text is stored in a single database table. We use a Microsoft Access (MS Access) database, but any database can be used. Only one table is required, with an index on the calling page’s name field. This method allows for ease of administration and future growth.
Now we are ready to query the HELP.MDB database and retrieve the help text (or HTML). Once retrieved, the help text will be inserted into the ASP help page and presented to the browser.
The first step is to create a table in your database of choice. The MS Access table design is as follows:
When normalizing a data design, you should create a completely independent primary key. In this case, we are using the field named ID, which is set to auto-increment for each new row. Column PageName is the calling page name from your application. PageTitle is a field used to hold a page title, which should be the calling page title since this will be displayed on the help screen. Finally, HelpText is the field used to hold all the required help text for your Web application’s page. The data for this field will be directly displayed on the help screen, so it is possible to store HTML code in this column.
That is it! This one database table contains all of your help text. Simply add whatever you wish to the HelpText field to be displayed on the PageName. This design can hold an unlimited number of help pages.
The benefit of MS Access Memo fields is that they will accept up to 64,000 characters, so you can create help pages with your favourite HTML editor and then simply copy and paste the HTML document code between <body> tags into an MS Access Memo field. The same principle would apply to creating the whole Web application or site with only one main page, one database, and one ASP page used to send responses to the user. You could replace the whole site by replacing only one file (database). From a security point of view, using the same idea, you could encrypt the entire database and make it very hard for the “hacker” to crack your site.
Almost any database can be used, but remember that if you select Sybase Inc.’s SQL Server for your back-end database, you will have to use either a text data type or multiple-character (char) data-type columns in order to store your WWW pages. There is no direct equivalent of the MS Access Memo field in the SQL Server database engine.
Accessing the Database
Let’s open a database connection. In this example, the database is accessed using file DSN, thus removing the ODBC connectivity requirements to the database. If you wish to use an ODBC connection, simply create an ODBC entry in your ODBC Administration utility and use that ODBC name to connect to the database. (If you are using ODBC rather than file DSN, some code changes will be required.)
<%
'---- Define variables.
Dim strPageTitle
Dim strHelpText
'---- Get the row for the invoking page from HELP.MDB database
sql = "select PageTitle, HelpText from Help where PageName= '"+WhoNeedsHelp+"'"
'---- Open ODBCless connection to Help MS Access database
DB = "HELP.mdb"
Dir = Request.ServerVariables("SCRIPT_NAME")
Dir = StrReverse(Dir)
Dir = Mid(Dir, InStr(1, Dir, "/"))
Dir = StrReverse(Dir)
Path = Server.MapPath(Dir) & "\"
File = "help.dsn"
DSN = "filedsn=" & Path & file & ";DefaultDir=" & Path & ";DBQ=" & Path & DB & ";"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open DSN
Set RS = Conn.Execute(SQL)
%>
The above script will establish a connection to the database and execute the SQL query. The query result is either one row containing the PageTitle and HelpText for the invoking page (PageName) or no row at all.
If you are going to try this example on your ISP server or your local installation of IIS 4.0, you must assign read, write, create, and delete rights to the subdirectory containing your MS Access file. In this case, I recommend creating a separate directory underneath your Web home directory. For example, if your root is in c:\inetpub\wwwroot, you should create a subdirectory called test and place your help.mdb file in it (i.e., c:\inetpub\wwwroot\test\help.mdb).
If for some reason there is no returning row from the database (this could mean that you did not update the help table when you added a new page to your Web site), the following code will return the help-inquiring user back to the original page. Presenting the user with a page saying the help record is not available and then returning to the referring page could enhance this part.
<%
'---- If there are no records for this page:
'---- Close the database connection and go back to the Invoking page.
If RS.EOF or RS.BOF then
'---- Close the database connection.
Conn.Close
Set RS = nothing
Set Conn = nothing
'---- Go back to the Invoking page.
Response.Redirect(Request.ServerVariables("HTTP_REFERER"))
End if
%>
If a row was found in the database, capture the PageTitle and HelpText for the page in questions as follows:
This information will be used to personalize each page with an appropriate page name (PageTitle) and body of the page (Help Text):
<%
'---- Capture the database data.
strPageTitle = RS("PageTitle")
strHelpText = RS("HelpText")
'---- Close the database connection.
Conn.Close
Set RS = nothing
Set Conn = nothing
%>
The Returning Help Page
At this point, we have all we need to show the user the requested help page containing help text for the specific page in question.
The following puts it all together on the returning help page in the browser. Take note of strPageTitle several lines down. First, we return our banner logo, followed by the generic “Help for” and the page title from the database. This allows the user to recognize which page he/she requested help for.
The following code determines what to do if there is no help text entered in the database for the page in question. If this happens, we do not want to display a blank help page, so we display a “Coming Soon” page with “under construction” text, as follows:
<%
'---- If there is a record for this page but no data in the HelpText field,
'---- Display “Under Construction” message.
If strHelpText="Null" then
%>
<tr>
<td align="center"><img src="undercon.gif" width="40" height="38"></td>
</tr>
<tr>
<td align="center"> <font face="Comic Sans MS" size="2"><b>This page
is under construction. Please try
again later.</b></font></td>
</tr>
<%else%>
If we have the record returned from the database and data exists for the requested page, the following code will be executed:
The database field HelpText, with its contents, has been applied here with all of the HTML tags that are stored in our table (Memo field).
Return to Calling Page
The following code will display a Back button. When clicked, the flow will return the browser to the original page that started this entire help journey. This is where the use of server variables HTTP_REFERER comes into play. The same effect could be accomplished by passing a parameter to the ASP page as follows: HELP.ASP?Page=Page1.htm. Using the server variables is more elegant and easier to maintain, which is one of my objectives.
It is important to note that a higher level of security can be achieved if a check is done somewhere in ASP code. This would ensure that page requesting help is coming from your server. This can be done by using the server variable (in IIS 4.0 case) SERVER_NAME. The check ensures that only requests from your server will be processed and this will make the efforts of a potential “hacker” somewhat more difficult.
Conclusion
This clean, simple method integrates a help system into your Web applications. I would imagine that similar solutions are possible with different types of Web servers, as long as the server software supports server variables that will notify the target page of the name of the sending HTML or ASP document. With an Apache WWW server that will be REFERER_URL. One of the possible enhancements is to pass parameters, for example, which will invoke different types of help document (HTML) templates for different levels of your WWW application.
Download
Want to try it out? Download an entire working example from our Web site at http://15seconds.com/files/991111.zip. This sample is created with four HTML documents and one ASP document that returns a help document for the referring page. Each of the HTML pages will invoke different actions - plain HTML response, Java response, page not available, and page under construction. Feel free to use this code in your applications..
About the Authors
Srdjan Vujosevic is a system analyst with the Bank of Butterfield in Bermuda. Srdjan has more than 15 years of hands-on experience with many programming languages and databases, including VB, HTML, Java, ASP, SQL Server, Sybase, MS Access, and systems integration (client/server, CTI, etc.)
Bob Laberge is a database administrator with the Bank of Butterfield in Bermuda. Bob has nearly 20 years of experience with databases, data warehousing, enterprise data architecture, and legacy systems integration from mainframes to personal computers.
Proposion N2N connects Microsoft .NET applications to Lotus Notes and Lotus Domino databases. This ADO.NET managed data provider allows you to perform blindingly fast queries and updates of Notes data from ASP.NET pages, .NET web services, Windows, or Mobile applications. An innovative SQL-like query language leverages the unique features of Notes and makes collaborative software accessible to relational database programmers.
Unlike text-based file formats image files aren't made up of words, which makes searching for an image file by keyword difficult. Instead of being able to simply open the file to see what it contains, we're stuck looking at the text around it and other metadata to determine the image's meaning. In this article, Ziran Sun shows you how to build a simple database-based image keyword system that allows you to associate keywords with images and use these keywords to make finding images easier. [Read This Article][Top]
In the second part of of his article on using MySQL with ASP.NET, Ziran Sun covers how to add a new MySQL user to the database server, assign the user the appropriate permissions, connect to the database, and build a simple ASP.NET page to perform a query. [Read This Article][Top]
Back in the days of classic ASP, if you were building a database-driven
web site, your choice was either to invest a lot of money to get a copy of Microsoft SQL Server
(or some other enterprise-ready database) or invest a lot of time finding a way to deal with the
performance and scalability limitations of Microsoft Access. Luckily these days there's
another viable alternative: MySQL. [Read This Article][Top]
Moving or copying a SQL Server database from one machine to another requires a lot of preparation in order to ensure a smooth transfer. In this article, Dina Fleet Berry examines the different methods and highlights the different issues associated with each of them. [Read This Article][Top]
There are many times when using SQL Server 2000 Query Analyzer to debug SQL statements is a better choice than debugging in Visual Studio .NET. In this article, Dina Fleet Berry explains why and walks you through the debugging process step-by step. [Read This Article][Top]
As a follow up to his article on retrieving objects from SQL Server using SQLXML and serialization, Gianluca Nuzzo discusses saving objects back to SQL Server using a schema definition file and updategrams. [Read This Article][Top]
One area that stands out when comparing ADO.NET 1.x to ADO.NET 2.0 is transaction processing. Bill Ryan shows just how easy transaction processing has become with the TransactionScope object in ADO.NET 2.0. [Read This Article][Top]
Developers often use brute force coding to marshal data between the GUI and application objects. In this article, Luther Stanton explains how to use .NET's out-of-the box data-binding functionality to make this job much easier. [Read This Article][Top]
Learn how to create a console application to queue a message in Microsoft Message Queuing (MSMQ) and then use an extended stored procedure to call the console application from a SQL Server trigger. [Read This Article][Top]
Connection pooling increases the performance of Web applications by reusing active database connections instead of creating a new connection with every request. This article shows how to monitor the connection pool, diagnose a potential problem, and apply the appropriate fix. [Read This Article][Top]
Mailing List
Want to receive email when the next article is published? Just Click Here to sign up.