Comprehensive, categorized, searchable collection of links to ASP & ASP.NET resources...
ASP.NET Directory

Applications
Assembly & Controls
Books & Media
Community
Other ASP.NET Sites
Reference Material
Software & Server
Tutorials & Code
Web Site Hosts

ASP Directory

Applications
ASP.NET Directory
Books & Media
Community
Components
Other ASP Sites
Reference Material
Software & Server
Tutorials & Code
Web Site Hosts

Newsgroups

Participate in over
100 ASP & ASP.NET related newsgroups right here @ Fuzzy Software...

.NET Framework
- .net.faqs
- .net.framework
- .net.general
- .net.setup
- .net.scripting
- .net.xml

Web Services
- aspnet.webservices
- msdn.soaptoolkit
- msdn.webservices

SQL Server
- sqlserver.setup
- sqlserver.prog...
- sqlserver.tools

Classic ASP
- asp.db
- asp.general
- asp.components

Scripting
- scripting.jscript
- scripting.remote
- scripting.vbscript
- scripting.wsh

All newsgroups...

ASP Built-in
Objects Reference


Application Object
ObjectContext Object
Request Object
Response Object
Server Object
Session Object

Personalise Fuzzy
Make Homepage
Link To Fuzzy
Bookmark This Page

Add our directory to your site in less than
2 minutes...



ASP.NET Chart and Charting for .NET








Whats New!
The QueryString collection retrieves the values of the variables in the HTTP query string. The HTTP query string is specified by the values following the question mark (?). Several different processes can generate a query string. For example, the anchor tag

<A HREF= "example?string=this is a sample">string sample</A>

generates a variable named string with the value "this is a sample". Query strings are also generated by sending a form, or by a user typing a query into the address box of their browser.

Syntax

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

Parameters

variable
Specifies the name of the variable in the HTTP query string to retrieve.
index
An optional parameter that enables you to retrieve one of multiple values for variable. It can be any integer value in the range 1 to Request.QueryString(variable).Count.

Remarks

The QueryString collection is a parsed version of the QUERY_STRING variable in the ServerVariables collection. It enables you to retrieve the QUERY_STRING variables by name. The value of Request.QueryString(parameter) is an array of all of the values of parameter that occur in QUERY_STRING. You can determine the number of values of a parameter by calling Request.QueryString(parameter).Count. If a variable does not have multiple data sets associated with it, the count is 1. If the variable is not found, the count is 0.

To reference a QueryString variable in one of multiple data sets, you specify a value for index. The index parameter may be any value between 1 and Request.QueryString(variable).Count. If you reference one of multiple QueryString variables without specifying a value for index, the data is returned as a comma-delimited string.

When you use parameters with Request.QueryString, the server parses the parameters sent to the request and returns the specified data. If your application requires unparsed QueryString data, you can retrieve it by calling Request.QueryString without any parameters.

You can use an iterator to loop through all the data values in a query string. For example, if the following request is sent

http://NAMES.ASP?Q=Fred&Q=Sally
 

and Names.asp contained the following script,

---NAMES.ASP---
<%
For Each item In Request.QueryString("Q")
  Response.Write item & "<BR>"
Next
%>
 

Names.asp would display the following.

Fred
Sally
 

The preceding script could also have been written using Count.

<%
For I = 1 To Request.QueryString("Q").Count    
  Response.Write Request.QueryString("Q")(I) & "<BR>"
Next
%>
 

Example

The client request

/scripts/directory-lookup.asp?name=fred&age=22
 

results in the following QUERY_STRING value.

name=fred&age=22.
 

The QueryString collection would then contain two members, name and age. You can then use the following script.

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

The output would be

Welcome, Fred. Your age is 22.
 

If the following script is used

The unparsed query string is:  <%=Request.QueryString %>
 

The output would be

The unparsed query string is: name=fred&age=22
 

Applies To

Request Object

See Also

ClientCertificate, Form, QueryString, ServerVariables






$10/mo & 3 Months FREE!


Receive all the latest quality ASP
& ASP.NET content direct to your inbox. Sign-up to our newsletter.






DevDirect.com - Tools and Components for Software Developers

CodeFixer

ASPNET World.com

WebWizGuide

More partners...

deloittes.NET AdServe - ASP.NET Ad Management, Tracking and Reporting
  9969 ASP & ASP.NET resources in over 483 categories and growing daily...
Fuzzy Software - asp / asp.net resources, tutorials, code, scripts, applications, components, newsgroups, hosts and much more... Sitemap 0 1 4