Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP submit page

Status
Not open for further replies.

dom24

Programmer
Aug 5, 2004
218
GB
Can someone please tell me how I add an arror message to an ASP page when the user submits an empty page?
I know Javascript would work but I've never used it before so was wondering if there was some html/asp way of doing it?
At the moment when the page is submitted blank it goes to another page which displays the error message, however I have lots of response objects on there so I also get an error when it carries on reading the code. I want it to just stop after the error message and go back to the original submit page.
See code below:

Thanks.


If Request.QueryString("StaffNo")="" then
Response.Write "You must enter your staff number or select your surname."
Else
strSQL = "SELECT * from Staff, Validation where staff.staffno = validation.staffno and staff.staffno = '" & Request.QueryString("StaffNo") & "'"
End If

GetConnection
Set objRS = CreateObject("ADODB.Recordset")
objRS.Open strSQL, Conn
%>
<input type="text" value="<%=objRS("LName")%>" name="LName">
<input type="text" value="<%=objRs("FName")%>" name="FName">
<input type="text" value="<%=objRS("StaffNo")%>" name="StaffNo"><p>
<input type="text" value="<%=objRS("Location")%>" name="Location">
<input type="text" value="<%=objRS("ManagerNo")%>" name="ManagerNo"><p>
<input type="text" value="<%=objRS("CourseKey")%>" name="CourseKey">
<input type="text" value="<%=objRS("CourseDate")%>" name="CourseDate">
<input type="text" value="<%=objRS("TrainerNo")%>" name="TrainerNo">
<%
 
Is this what you are looking for?

If Request.QueryString("StaffNo")="" then
Response.Write "You must enter your staff number or select your surname."

response.redirect "originalpage.asp"

Else
strSQL = "SELECT * from Staff, Validation where staff.staffno = validation.staffno and staff.staffno = '" & Request.QueryString("StaffNo") & "'"
End If
 
I tried that but I get this error:

You must enter your staff number or select your surname.
Response object error 'ASP 0156 : 80004005'

Header Error

/Evaluation/name4.asp, line 22

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.
 
you cannot do a Response.Redirect if you have already written content to the page. You have done this with the Response.Write.

Tony
________________________________________________________________________________
 
Done it thanks.
All I did was put Response.Buffer = true at the top of my page then the response.redirect didin't cause an error.

I had to take the response.write out though as it just goes back to the original page straight away without displaying anything.

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top