![]() |
|
|
+ Search |
![]()
|
Nov 22nd, 2006 21:36
Christopher Gardiner, Alvin Zhang, Willem van den Berg, Cory Krieger,
This can be extremely handy, especially if you are planning to check a
database to, let's say, check whether a username is already taken
(when someone is signing-up for your site) and retain all of the other
form information so that the user does not have to retype it. This is
the best ASP 3.x solution.
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
fName = Request("Fname")
lName = Request("Lname")
nick = Request("Nickname")
eMail = Request("Email")
password = Request("Password")
If Request("Password") = Request("ReEnterPassword") Then
'Check database to make sure the username and email
'address are not taken
'If not, post the new user information to the database and
Response.Redirect("userhomepage.asp")
End if
End if
%>
If the page does not get redirected, then either the username or
password were rejected, or the Password and Re-Enter Password fields
did not match. The page will continue back to the original form and
you can then add the previously-entered values to your fields so that
your users don't have to re-enter them:
<input type="text" name="Fname" value="<%=fName%>">
<input type="text" name="Lname" value="<%=lName%>">
For much more detail including storing to a database, see
http://www.faqts.com/knowledge_base/view.phtml/aid/34309
Happy ASPing!
Other Methods:
I am assuming you are trying to ask whether you can post and receive a
response in the same ASP Page. This is possible with asp.net via a
function but in asp, there is no direct built-in function to
accomplish this task. However there is a work-around for this task.
Anyway, hope that the code helps because I did not test the code and I
just typed it off-hand before going to bed.
Method 2
>>form.asp
<%
ChkPostBack = request.querystring("ispostback")
if ChkPostBack = "1" then
'if ChkPostBack returns 1, then this is a post back
'insert your code here
Replytxt = request.form("Replybox")
'you might want to do error checking here
response.write(Replytxt)
else
'if the user is looking at the page for the first time
%>
<form action="form.asp?ispostback=1" method="post">
<input type="text" name="Replybox">
<br>
<input type="submit">
</form>
<%
end if
%>
Method 3
>>form.asp
<%
ChkPostBack = request.form("ispostback")
if ChkPostBack = "1" then
'if ChkPostBack returns 1, then this is a post back
'insert your code here
Replytxt = request.form("Replybox")
'you might want to do error checking here
response.write(Replytxt)
else
'if the user is looking at the page for the first time
%>
<form action="form.asp?ispostback=1" method="post">
<input type="text" name="Replybox">
<br>
<input type="submit">
<input type="hidden" name="ispostback" value="1">
</form>
<%
end if
%>
© 1999-2004 Synop Pty Ltd