homepage Welcome to WebmasterWorld Guest from 54.224.179.98
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Request.Querystring, arrays and data types
Receptional Andy




msg:4043329
 10:15 am on Dec 15, 2009 (gmt 0)

I'm accessing what appears to be an array via Request.QueryString - indeed, I can loop through these values. I'm using this as a rough equivalent of $_GET in PHP.

However, the data type of Request.Querystring is a string, which means many array functions can't be used.

Is there an easy way for me to make Request.Querystring a "real" array, or is there some other flaw in my approach?

 

marcel




msg:4043332
 10:25 am on Dec 15, 2009 (gmt 0)

Hi Andy, are you using Classic ASP or ASP.Net?

Receptional Andy




msg:4043333
 10:27 am on Dec 15, 2009 (gmt 0)

Classic ASP, unfortunately ;)

Receptional Andy




msg:4043359
 11:34 am on Dec 15, 2009 (gmt 0)

I'm trying the following to create an associative array from the query string:

Dim getArray
set getArray = Server.CreateObject("Scripting.Dictionary")

For each Key in Request.QueryString
getArray.Add Key, Request.QueryString(Key)
Next

Is this a reasonable method?

Ocean10000




msg:4043448
 2:53 pm on Dec 15, 2009 (gmt 0)

Why are you trying to put it in an dictionary object when Request.QueryString is a advanced collection object to begin with? You do not gain anything that I can think of by doing this?

Reference
Request.QueryString Collection [msdn.microsoft.com]

Receptional Andy




msg:4043459
 3:07 pm on Dec 15, 2009 (gmt 0)

Thanks for the link :)

The two reasons for this are that the dictionary object allows me to remove individual items, and because I want to manipulate the data. I'd rather keep Request.QueryString as the raw data from the query string.

The code I'm using is to loop through the items, but removing one at the end of each loop, e.g. in an array of three items:

1,2,3
1,2
1

My troubles started when I could not find an easy way to remove items from an array in classic ASP. I'm afraid I'm used to PHP where there's a function to knock the last item off an array. Most probably, there is an entirely different approach I should be using.

bmcgee




msg:4044558
 5:01 am on Dec 17, 2009 (gmt 0)

redim preserve myarray(ubound(myarray) - 1)

Seb7




msg:4060960
 8:58 pm on Jan 14, 2010 (gmt 0)

what about:

myarray = split(request.querystring(),"&")

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved