|
Jamal Aljahmi Asks a Seemingly Simple Question:
I'm doing some error handling to check for ado sql error. Once the error is
found I would like to redirect to the calling form but write a message at
the top or bottom of the calling form. Any suggestions on how to do that.
Chaz Punches Out This Code:
Well, take this psuedo code for example:
TestScript.asp
Dim variables
set variables = to form input
if there are form input errors then
errFlag = true
errMsg = "there were form input errors"
if this is a form submission then (ie: if request("btnSubmit") <>
"" then)
update the database
if there were datbase update errors then
errFlag = true
errMsg = "there were database errors"
query the database to get the latest data
if errFlag then
display errMsg
display queried data
The Plot Thickens. Says Jamal:
Oh, your doing the error message on the same page. I wanted to write
the error message back to the redirected page.
Puzzled, Chaz Adds:
Well, if you must have it on the redirected page then you can pass the
message in the URL. Or you could come up with a complicated scheme where
you have standard error messages in a database and then all you have to pass
on the URL are ID numbers for the appropriate message. Seems pretty
complicated when you can just put all the processing on one page with
everything you need.
Rob Chartier Then Posits:
You could have a table, with custom error messages and IDs (hard-coded
errors) and when you redirect back and need to show the errors, you
only need to pass the custom message id, query the DB to get the error message, and then
show it.
You could even go so far as having a table with just ids and error
message (dynamic errors).
Your error handler will log to that error table, and when it redirects back, it
passes those NEW ids over, pick them up and show them. This would be kinda recommended
because then you will have a good log ofall of the errors.
You can analyse and check to see what are common errors
and re-evaluate your usability for the site like say, the "signup.asp"
page has a ton of problems with the "first name" field never being filled
in. When upon discovery you can reformat the signup.asp page to show the
first name field more prominently etc..
This conversation string was taken from the 15Seconds ASP Listserv on 1/24/01.
If you have an ASP-related question or would like to share some of your knowledge
with others, you may join the list by clicking here.
|