Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Loop round all querystring parameters?

Reply
Thread Tools

Loop round all querystring parameters?

 
 
Mike
Guest
Posts: n/a
 
      08-17-2005
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.


 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      08-17-2005
"Mike" <> wrote in message
news:%...
> 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?


 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      08-17-2005
Mike wrote:
> "Mike" <> wrote in message
> news:%...
>> 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"


 
Reply With Quote
 
Phill. W
Guest
Posts: n/a
 
      08-17-2005
"Mike" <> wrote in message
news:%...
> 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.


 
Reply With Quote
 
Phill. W
Guest
Posts: n/a
 
      08-17-2005
"Bob Barrows [MVP]" <> wrote in message
news:%23dD%...
> Mike wrote:
> > "Mike" <> wrote in message
> > news:%...
> >> 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.


 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      08-17-2005
"Bob Barrows [MVP]" <> wrote in message
news:%23dD%...
> Mike wrote:
>> "Mike" <> wrote in message
>> news:%...
>>> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
So, round and round... 70-682... MSLearning, please read! DaGenester MCITP 2 05-20-2010 04:36 PM
VS2005 - Going round and round in circles again :) postings@alexshirley.com ASP .Net 0 06-22-2006 11:26 AM
Float.round - should it be round-to-even OliverMarchand Ruby 2 04-12-2006 12:06 PM
Computer Goes Round and Round Checking Alan Computer Support 6 10-08-2004 08:24 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57