Get post values between two pages

L

Luigi

Hi all,
in an aspx Page_Load event, how can I get a textbox value taken from the
previous page?

Example
Page1.aspx with textbox and button that redirect to Page2.aspx

In this page I'd like to set a label with the textbox value from the first
page.

Thanks a lot.

Luis
 
L

Luigi

:
Several ways, but the two simplest are:
1) Pass it as a QueryString name/value pair:
http://www.google.co.uk/search?aq=f&sourceid=chrome&ie=UTF-8&q=ASP.NET+QueryString

2) Use a Session variable
http://www.google.co.uk/search?hl=en&q=ASP.NET+Session+variable&btnG=Search&meta=

1) takes up no server memory, but the value is visible in the address bar
and could, in theory, be inspected or changed by the user.

2) takes up a bit of server memory (almost certainly only a tiny amount),
but the value is hidden from the user.

Thanks Mark,
I'm trying this in Page2.aspx

protected void Page_Load(object sender, EventArgs e)
{

TextBox txtbox1;
txtbox1 = (TextBox)PreviousPage.FindControl("text1");
Label1.Text = txtbox1.Text;

}

but got me an null exception (the "text1" textbox exist in Page1.aspx).

My button in Page1.aspx is:

<input type="button" value="Continue" id="button2" name="button2"
onclick="return OnButton2();" />


and

function OnButton2() {
document.URL = "Page2.aspx";
return true;
}

Maybe the problem is on javascript function?

Luis
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top