Get post values between two pages

  • Thread starter Thread starter Luigi
  • Start date Start date
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
 
:
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
 
Back
Top