WebReference.com - Universal Related Pop-up Menus - Single Form Version II - (6/6)
URPM: Single Form Version II
The following code, located in the showErrors.inc file, should be placed somewhere in the body of the Web page, to display a generic message to the user if any errors are encountered along the way. Used in conjunction with the "On Error Resume Next" statement, it allows the page to be displayed along with a more meaningful error message:
<% If Err.number Then 'display error message Response.write("<font color=red><p><b>The following error occurred while loading the listboxes:</p>" & vbCrLf) Response.write("<p>" & Err.number & ": " & Err.description & "</b></p></font>" & vbCrLf) End If %>
I simply displayed the error number and description of the last error, but you could check for specific errors and display different messages depending on what happened. Also keep in mind that more than one error could occur along the way. Every time a new one is encountered, the Err Object is updated with the latest error details, and wipes out the old one in the process. To get around this, you might want to store all the errors in some sort of array and display the whole list. The Err object contains other useful properties you can access to gain more information about errors. I won't go into all of them here, as they can be found in any ASP documentation.
arrays into one multi-dimensional Object array used to link the list items.
My main reason for doing this was because I found the "O" Objects'
syntax difficult to master. Having transferred the responsibility
of populating the menu data to an ASP script, I now realize that I could bypass
the extra step of creating individual arrays completely. You could argue that
the code might not be as easy to read, but is this really important if the script
is organizing the data? Without looking at the source code, a little
testing of your page would quickly tell you if the items are coming up properly.
Writing the code to accomplish this would be guaranteed to be a hair-pulling
experience, but the improved performance would quite likely be worth
Download the full script (zipped file)
# # #
About the author:
Rob Gravelle is both a successful Internet Systems Developer as well as the guitarist for the melodic metal band Ivory Knight. He received a B.A. Mus from Carleton University in 1995, followed by a diploma in Computer Programming from Algonquin College in 1998. He now designs large-scale systems for National organizations at Citizenship and Immigration Canada. You can reach him at email@example.com.
Written by Robert Gravelle and
Created: October 2, 2001
Revised: October 2, 2001