Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

ASP QueryString Collection


❮ Complete Request Object Reference

The QueryString collection is used to retrieve the variable values in the HTTP query string.

The HTTP query string is specified by the values following the question mark (?), like this:

<a href= "test.asp?txt=this is a query string test">Link with a query string</a>

The line above generates a variable named txt with the value "this is a query string test".

Query strings are also generated by form submission, or by a user typing a query into the address bar of the browser.

Note: If you want to send large amounts of data (beyond 100 kb) the Request.QueryString cannot be used.

Syntax

Request.QueryString(variable)[(index)|.Count]

Parameter Description
variable Required. The name of the variable in the HTTP query string to retrieve
index Optional. Specifies one of multiple values for a variable. From 1 to Request.QueryString(variable).Count

Examples

Example 1

To loop through all the n variable values in a Query String:

The following request is sent:

https://w3.p2hp.com/test/names.asp?n=John&n=Susan

and names.asp contains the following script:

<%
for i=1 to Request.QueryString("n").Count
  Response.Write(Request.QueryString("n")(i) & "<br>")
next
%>

The file names.asp would display the following:

John
Susan

Example 2

The following string might be sent:

https://w3.p2hp.com/test/names.asp?name=John&age=30

this results in the following QUERY_STRING value:

name=John&age=30

Now we can use the information in a script: 

Hi, <%=Request.QueryString("name")%>. 
Your age is <%= Request.QueryString("age")%>.

Output:

Hi, John. Your age is 30.

If you do not specify any variable values to display, like this:

Query string is: <%=Request.QueryString%> 

the output would look like this:

Query string is: name=John&age=30

❮ Complete Request Object Reference
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.