PDA

Click to See Complete Forum and Search --> : Posting Data between different web forms


Auld Nick II
Jun 16th, 2003, 08:58 AM
I'm trying to pass data from one aspx page to another using a form.

I want to recieving page to have access to this data either through something similar to the traditional request.form metod or by some other way, I would like to be able to enumerate through the values as well but this is a nice to have. I'm also using c# although vb.net examples are just as welcome.

Anybody got any advice.

Cheers

Cander
Jun 16th, 2003, 09:09 AM
what is wrong with request.form?

Auld Nick II
Jun 16th, 2003, 11:03 AM
Request.Form won't work because I'm not submitting a form to a a new page, I'm calling an event on my first page, from which I then want to transfer the data. I've tried using the Server.Transfer method and this works fine, but I really need to be able to enumerate through the Request.Form collection (or any collection) and can't seem to get this bit.

hellswraith
Jun 16th, 2003, 11:08 AM
Can you use a query string? If you can, you can use Request.QueryString() method to retrieve a NameValue collection. You can then refer to individual values by name, and I think since it is a collection, you can probably enumerate through them.

You can find the NameValue collection object in the System.Collections.Specialized

Auld Nick II
Jun 16th, 2003, 11:10 AM
That's definately an option, but I'm sure there must be a way to transfer the entire form so that it can be referenced. I'll keep trying.

BradRoberts
Jun 16th, 2003, 11:38 AM
Try the Server objects Transfer method.

Cander
Jun 16th, 2003, 11:50 AM
well. Request.Form is also a collection so you should be able to iterate through it as well. Problem is, when you set the 2nd parameter of Server.Transfer to True in order to persist the Request values to the new page, it give an error about invalid Viewstate. :confused:

Auld Nick II
Jun 17th, 2003, 03:15 AM
Yes the server.transfer method was so full of promise if not for that problem with viewstate. My solution to this is just to use bog standard HTML controls on the search criteria form, which is probably more efficient in terms of server resources anyway, although I've got to admit a bit disappointing because I wanted to keep the structure of my application consistent. I can access values of individual controls on the sending page, I just can't iterate through them using foreach even when I set the public property of the sending page as a collection and return this (c# equivalent to me). If anyone ever stumbles across an answer to this I would be delighted to here about it.
Cheers,

Nick