ASP QueryString Collection
Complete Request object reference manual
The QueryString collection is used to retrieve variable values from the HTTP query string.
The HTTP query string is specified by the values after the question mark (?), for example:
The code above generates a variable named txt with the value "this is a query string test".
Query strings can also be generated by form submissions, or by a user entering a query in the browser's address bar.
**Note:** If you need to post large amounts of data (more than 100kb), you cannot use Request.QueryString.
Syntax
Request.QueryString(variable)[(index)|.Count]
| Parameters | Description |
|---|---|
| variable | Required. The name of the variable to retrieve from the HTTP query string. |
| index | Optional. Specifies one of multiple values for a variable. From 1 to Request.QueryString(variable).Count. |
Example
Example 1
Iterate over the values of all variables n in the query string:
Suppose this is the request that is sent:
http://www.w3cschool.cc/test/names.html?n=John&n=Susan
and names.asp contains the following code:
<%
for i=1 to Request.QueryString("n").Count
Response.Write(Request.QueryString("n")(i) & "
")
next
%>
The file names.asp will display:
John
Susan
Example 2
Suppose this is the string that is sent:
http://www.w3cschool.cc/test/names.html?name=John&age=30
The code above produces the following QUERY_STRING value:
name=John&age=30
Now we can use this 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, for example like this:
Query string is: <%=Request.QueryString%>
the output will look like this:
Query string is: name=John&age=30
Complete Request object reference manual