ASP QueryStringCollection
Complete Request Object Reference
The QueryString collection is used to retrieve the values of variables in the HTTP query string.
The HTTP query string is specified by the values after the question mark (?), for example:
<a href= "test.html?txt=this is a query string test">Link with a query string</a>
The above code can generate a variable named txt with the value "this is a query string test".
The query string can also be generated by form submission, or by the user entering a query in the browser's address bar.
Note:If you need to POST a large amount of data (over 100kb), you cannot use Request.QueryString.
Syntax
| Parameter | 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. |
Examples
Example 1
Loop through the values of all variable n in the query string:
Assume this is the request being sent:
And names.asp contains the following code:
for i=1 to Request.QueryString("n").Count
Response.Write(Request.QueryString("n")(i) & "<br>")
next
%>
The file names.asp will display:
Susan
Example 2
Assume this is the string being sent:
The above code produces the following QUERY_STRING value:
Now, we can use this information in a script:
Your age is <%= Request.QueryString("age")%>.
Output:
If you do not specify any variable values to display, like this:
The output will become like this:
Complete Request Object Reference Other Extensions