Server.Redirect to post to another page question

G

Guest

I'm trying to post from Page1 to Page2.
Page1:
controlData.Value = "Data value";//controlData is HtmlInputHidden
// Request.Form["controlData"] would return: "Data"
Server.Redirect("Page2.aspx",true);

Page2:
string sData = Request.Form["controlData"] ;//would return: "Data"

Problem: sData gives me: "Data" where I want to get "Data value";
How else can I send the string to Page2 if I have the string just before
Redirect(ing) ?

Thanks,
Oleg
 
J

John Rivers

please see explanation below ...


Sorry, read 'Server.Transfer' where it says: 'Server.Redirect'

you have declared some html to be output ...
// Request.Form["controlData"] would return: "Data"

it would once this page was received by a browser
and a user clicked submit and then you received a request

but at this point it is just html on the way to the response buffer

and now you have transferred the current request
to a new page, you are missing a whole roundtrip
Page2:
string sData = Request.Form["controlData"] ;//would return: "Data"

Problem: sData gives me: "Data" where I want to get "Data value";
How else can I send the string to Page2 if I have the string just before
Transfer(ing) ?

i can think of a number of ways but ...
i think you need to read up on basic http
and then ask yourself if there isn't a cleaner
way to achieve whatever it is you are trying to achieve

what are you trying to achieve? what does the second page do?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top