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

Using URL parameters in an ASP page 1

Status
Not open for further replies.

raniweb

Technical User
Apr 26, 2004
66
US
Is there a way to grab a URL parameter and use it in an ASP page and then pass it on to the next page in the URL and use it on that page also? Any help would be greatly appreciated. Thank you!
 
I assume by parameters you mean QueryString values? Like:
mypage.asp?a=1&b=2

If so, then yes. Querystring values can be accessed using the Request.QueryString collection. For example, for my above link I could access the varibales a and b like so:
Code:
Response.Write " A is " & Request.QueryString("a") & "<br>"
Response.Write " B is " & Request.QueryString("b") & "<br>"

If you wanted the entire querystring value (everything after the ?) then you can get it simply by calling Request.QueryString without any arguments, so to make a link that has some the same querystring values you would do somehting like:
Code:
<a href="nextpage.asp?<%=Request.QueryString%>">Go To Next Page</a>

Hope this helps,
-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
Need an expensive ASP developer in the North Carolina area? Feel free to let me know.


 
You can get anything in the URL by using request.querystring

e.g

Code:
dim strName
strName = request.querystring("name")
response.write strName
would return

aaaa

you can then pass this string in future url's

Code:
<a href="next.asp?name=<%strName%>">next</a>
 
Hey,
Thank you so much for your help. It worked perfectly! Thanks again!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top