Home » Programming / Coding

Loop Through QueryString ASP .Net

25 November 2008 3,622 views No Comment

So how you loop through querystring in asp .Net?

The QueryString property is a NameValueCollection object. So you can do something like this(example shown using C#):

foreach (string key in Request.QueryString.Keys)
{
Response.Write(key+ ” “+Request.QueryString[key]+”<br/>”);
}

Request.QueryString[key] will give you the value for the key.

So if this is the url http://www.webcosmo.com/listing/Search.aspx?countryId=1&gId=2&dId=48

This loop with print out:

countryId 1

gId 2

dId 48

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.