473,387 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Loop round all querystring parameters?

Is it possible to loop round all querystring parameters in a web page (i.e.
access them without hardcoding them)?

I want to do this because I have a page that has different querystring
variables passed into it depending on the content of the calling page.
Aug 17 '05 #1
5 21700
"Mike" <mi**@hello.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Is it possible to loop round all querystring parameters in a web page
(i.e. access them without hardcoding them)?

I want to do this because I have a page that has different querystring
variables passed into it depending on the content of the calling page.


P.S. That would be querystring variables with names like

test_page.asp?var1=3&var2=2&var6=8&var9=6

How do I access var1, var2, var6 and var9 without hard coding them?
Aug 17 '05 #2
Mike wrote:
"Mike" <mi**@hello.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Is it possible to loop round all querystring parameters in a web page
(i.e. access them without hardcoding them)?

I want to do this because I have a page that has different
querystring variables passed into it depending on the content of the
calling page.


P.S. That would be querystring variables with names like

test_page.asp?var1=3&var2=2&var6=8&var9=6

How do I access var1, var2, var6 and var9 without hard coding them?


The following works with all the Request collections (Form, ServerVariables,
Querystring):

dim key
for each key in Request.Querystring
Response.Write key & ": " & Request.Querystring(key) & "<BR>"
next

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Aug 17 '05 #3
"Mike" <mi**@hello.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Is it possible to loop round all querystring parameters in a web page (i.e. access them without hardcoding them)?


Request.QueryString doesn't support a Contents property (like
Session) so you'll probably have to pull the QueryString apart
yourself, something like :

sQS = Request.QueryString
For Each eItem in Split( sQS, "&" )
sName = Left( eItem, Instr( eItem & "=", "=" ) - 1 )
Response.Write sName _
& " = " & Request.QueryString( sName ) _
& "<br>"
Next

Watch out; you may /still/ fall foul of URLEncode'd parameter names.

HTH,
Phill W.
Aug 17 '05 #4
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Mike wrote:
"Mike" <mi**@hello.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Is it possible to loop round all querystring parameters in a web page
(i.e. access them without hardcoding them)?
.. . . The following works with all the Request collections (Form,
ServerVariables, Querystring):

dim key
for each key in Request.Querystring
Response.Write key & ": " & Request.Querystring(key) & "<BR>"
next


Now how on Earth did I forget that???

Regards,
Phill W.
Aug 17 '05 #5
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Mike wrote:
"Mike" <mi**@hello.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Is it possible to loop round all querystring parameters in a web page
(i.e. access them without hardcoding them)?

I want to do this because I have a page that has different
querystring variables passed into it depending on the content of the
calling page.


P.S. That would be querystring variables with names like

test_page.asp?var1=3&var2=2&var6=8&var9=6

How do I access var1, var2, var6 and var9 without hard coding them?


The following works with all the Request collections (Form,
ServerVariables, Querystring):

dim key
for each key in Request.Querystring
Response.Write key & ": " & Request.Querystring(key) & "<BR>"
next

HTH,
Bob Barrows


Absolutely perfect, thanks.
Aug 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Derek | last post by:
I am trying to refresh one datagrid after updating another datagrid. I can not call BindData for one under the other bind sub because it creates an endless loops on page load. Is there way to...
4
by: .Net Sports | last post by:
I am trying to display records from a recordset after sql statement: <% sqlstr ="SELECT horsename FROM tblhorseentry WHERE trackname = '" & request.querystring("trackname") & "' and racedate =...
3
by: Nobody | last post by:
Hi -- I'm developing an ASP.NET application in VS.NET and I want the startup page to read in some parameters from a querystring. But I can't figure out where to set the querystring. I thought it...
5
by: Vishwanathan Raman | last post by:
I have only one page.Its a search results page.Depending on the component selected in the results page the search is initiated. I am using QueryString to send me details pertinent to search.But I...
2
by: Speedy | last post by:
Hi, I have this page http://www.monow.se/borg/mystat/klubb_filt.asp but I wan't it to look like this: http://www.monow.se/borg/mystat/wanted.asp this is my code:
1
by: Adeel Ahmad | last post by:
Hi, The subject sounds confusing but here is what i want to do. I have a button on my page which says...
5
by: Nirmal Singh | last post by:
I am a newbie trying to learn ASP.net 2.0. I want to retrieve the QueryString and process it to produce some parameters. I then want to redirect the user to another page, passing these...
0
by: mohaaron | last post by:
Hello all, I'm having a problem using the ReturnUrl parameter while using FormsAuthentication. If I already have some querystring parameters in the url like this. ...
4
by: | last post by:
Hi all, If I am reading this right, then the querystring parameters must be "&amp;" and not "&". However, IIS 6.0 and asp.net request.querystring fails to capture the values if "&amp;" is specified....
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.