473,544 Members | 1,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 21743
"Mike" <mi**@hello.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.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?v ar1=3&var2=2&va r6=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******** ********@TK2MSF TNGP12.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?v ar1=3&var2=2&va r6=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.Queryst ring
Response.Write key & ": " & Request.Queryst ring(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******** ********@TK2MSF TNGP12.phx.gbl. ..
Is it possible to loop round all querystring parameters in a web page (i.e. access them without hardcoding them)?


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

sQS = Request.QuerySt ring
For Each eItem in Split( sQS, "&" )
sName = Left( eItem, Instr( eItem & "=", "=" ) - 1 )
Response.Write sName _
& " = " & Request.QuerySt ring( 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******@NOyah oo.SPAMcom> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
Mike wrote:
"Mike" <mi**@hello.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.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.Queryst ring
Response.Write key & ": " & Request.Queryst ring(key) & "<BR>"
next


Now how on Earth did I forget that???

Regards,
Phill W.
Aug 17 '05 #5
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
Mike wrote:
"Mike" <mi**@hello.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.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?v ar1=3&var2=2&va r6=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.Queryst ring
Response.Write key & ": " & Request.Queryst ring(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
1521
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 rebind without the loop or how could I call page.refresh or at least close the window after one datagrid is updated. Any help? Thanks in advance...
4
5823
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 = '" & request.querystring("racedate");" Set rs1 = Server.CreateObject("ADODB.Recordset") rs1.Open sqlstr,pConn,3
3
5607
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 was in the Project Properties dialog under the Debugging tab. There's a dropdown box where you can set the start up page. But VS ignores the...
5
1462
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 need to have it cleared and not retain the values when its posted back. Can somebody throw some insight as to how to achieve this.
2
389
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
11630
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 OnClick="javascript:window.open('reports\\Container.asp?pageURL=Report1.asp?intCurrentPage=1&blnRetrieveFlag=1&Show=1',TasksRPT');" Now on the Conatiner.asp what i do is if Request.QueryString("Show") = 1 then pageURL =...
5
7671
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 parameters, but not as a querystring. Any help would be gratefully received.
0
1704
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. NonSecurePage.aspx?param1=value1&param2=value2 I now click a link to a secure page and I get redirected by FormsAuthentication to the login page and I get this.
4
9476
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. e.g. http://myserver/test.aspx?pid=1&amp;did=2 http://www.w3.org/TR/html401/appendix/notes.html#h-B.2.2 Any ideas?
0
7429
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7368
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7384
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5301
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3414
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
990
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
671
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.