Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP & Big Parameter Strings

Status
Not open for further replies.

Skittle

ISP
Sep 10, 2002
1,528
0
0
US
Hi,

I have an array variable set up in an ASP page which I want to make available to another ASP page called by the first.
The array is variable in length.

What is the best way to do this?
At first I thought about using a dictionary object as a session variable but the Wrox books advise against this.
Is a session level array variable a good way of doing it?


 
Depending on what is in the array you could try a few things.
Easiest way is probably through a form or the url string.
You could write out your array in one string, using a delimiter like : or --- or anything you think is appropiate.

Dim sNewString, i
For i = 0 To UBound(theArray)
If i > 0 Then
sNewString = sNewString & "---" & theArray(i)
Else
sNewString = theArray(i)
End If
Next

Now to pass a string to the next page, you can use a form field or a link
i'll use redirect for the example

Response.Redirect "nextpage.asp?mystring=" & sNewString

On the next page you can split the string in a new array:

Dim new_array
new_array = Split(request("mystring"),"---")

Of course it depends on the type of content you hold in the array and also the dimension of it. If we're handling big data try a form field (textarea for instance)

Other possible ways to pass data:
- through database
- through temporary text file (using FileSystemObject)

hope this helps
good luck with it
 
Using the same concept as above, a simpler way to turn the array into a delimited string is to use the Join() function.
Code:
Dim sNewString
sNewString = Join(myArray,"---")
The above code does exactly the same as the code in the post above. You can make the second string any string you want to use as a delimiter.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top