Forum Moderators: open

Message Too Old, No Replies

error messages

how to write custom

         

sirjon

8:49 am on Dec 4, 2002 (gmt 0)

10+ Year Member



I have my form and results on the same page (is this correct)?
Anyway, because they are on the same page, when the form is submitted and the record is not found, nothing happens.
I would like to have various messages written on the page that alert the user of the problem. ie. "sorry, this record does not exist," or "Please select another name."
I have looked everywhere for the answer and could use some help.
Cheers.

duckhunter

2:11 pm on Dec 4, 2002 (gmt 0)

10+ Year Member



Having the results and form in the same ASP is fine.

Open your Recordset and check for EOF to determine whether to write results or error messages

If rs.eof then
Response.write "No Records Found"
else
Do While not rs.eof
response.write rs.fields.....
rs.movenext
loop
end if

sirjon

9:47 am on Dec 6, 2002 (gmt 0)

10+ Year Member



Thanks Duckhunter,
I now have that working,except that when the user comes to
the page for the first time, they get the error message.
I want to keep my default values so that no records are shown but show another message - something like "welcome, please select..."
Can't work it out?

duckhunter

2:52 pm on Dec 7, 2002 (gmt 0)

10+ Year Member



I don't always advocate using Session Variables but this is one case where it works pretty good. When the user shows up for the first time the Session variable is null (You might want to initialize "BeenHere" to "NO" in the Session_Start of your global) and can tell you not to show the error message. Wrap the error text in an IF statement and when they choose one and move to the next page, set the Session("BeenHere") = "YES".

If rs.eof then
If Session("BeenHere") = "YES" then
Response.write "No Records Found"
else
response.write "Please Choose...."
end if
else
Do While not rs.eof
response.write rs.fields.....
rs.movenext
loop
end if