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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass parameter from html to asp page 3

Status
Not open for further replies.

arkadia93

Programmer
Oct 19, 2006
110
GB
I am trying to pass a parameter from a HTML page to an ASP page, but it doesn't work. Here is my HTML page :

<html>

<head/>

<body>

<FORM name="frmPost" action="test2.asp?user=<%=user%>" method="post">

<input type="text" name="user">
<input type="submit" value="Submit">


</form>

</body>

</html>

And my ASP page :


<html>

<head>
<title>Call UK Messenger</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<BODY>
<DIV>



Parameter passed :<BR><BR>
<TABLE BORDER=1>
<TR>
<TD><% Response.Write Request.QueryString("user") %></TD>
</TR>
</TABLE><BR><BR>

</DIV>

</body>
</html>

Can somebody please advise?

 
How to retrieve data:
Request.Form() - collection of data from a form POST
Request.QueryString() - collection of data from a form GET or URL querystring
Request() - allows simple access to the collections .Form, .QueryString, .Cookies, .ServerVariables

So in this case since your form has a method of POST you would want to use Request.Form to get the vaue in your second page, not Request.QueryString

-T

 
I get a message box 'Do you want to open or save this file?' for the ASP page, rather than the page being opened. Do you know why this might be?
 
Here is my HTML page :

<html>

<head/>

<body>

<FORM name="frmPost" action="test2.asp?user=<%=user%>" method="post">

<input type="text" name="user">
<input type="submit" value="Submit">

If that is your HTML page then why is <%=user%> in there?

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
Sorry about that, is there a way I can pass the value in the user input box to the asp page without using ASP?
 
If you get that error message, then most likely you don't have IIS set up in the folder you're using this on, or you're viewing the page locally.

Lee
 
If you want to pass form element values in the URL, use method="get" in the form tag. Your current code is attempting to use ASP backwards, from the client browser to the server.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top