ASP QueryString Collection

Saturday, September 1, 2012

tags ASP

In this ASP tutorial, we will be taking a look at how to pass variables and their values to an ASP page using the QueryString Collection, and how to access them from the target page. While you may not be an expert using query string, you certainly have seen one used before in a URL. For example, you may have been on an Internet site looking up a product in an online catalog and saw that the URL looked something like "". In this example, the variable, products with a value of books was being passed from one page to the next. The question mark in the URL indicates the start of the query string and the ampersand (&), symbol separates the variables, if more than one exits. We can use the QueryString collection to access the variable and values in the query string on the target page.




variableSpecifies a string or numeric 1-based index of the parameter_name
indexSpecifies one of multiple values for a variable, or index of the parameters in the query string
countSpecifies the number of multiple values for a variable or number of variables in the query string


Lets take a look at some specific examples on how to use the Request.QueryString collection to access the information contained within the query string. The example URL is as follows:

Request.QueryString(2)5, 4
Request.QueryString("a")1, 3, 6, 7

Once you understand how to access the variable or variables in a query string, the next step is to determine what to do with those values. You may use that information to log a person into an application, or look up product information stored in a database. Finally, after you have process the query string information, display the dynamic data back to the end user.

Did you find the page informational and useful? Share it using one of your favorite social sites.

Recommended Books & Training Resources

ASP In A Nutshell Sams Teach Yourself Active Server Pages 3.0 in 21 Days Beginning ASP Databases