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 "www.website.com/catalog.asp?products=books&category=computers". 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.
|variable||Specifies a string or numeric 1-based index of the parameter_name|
|index||Specifies one of multiple values for a variable, or index of the parameters in the query string|
|count||Specifies 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: http://www.website.com/page.asp?a=1&b=5&a=3&a=6&a=7
|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.
Recommended Books & Training Resources