CrossPagePostBack

Please! Need Help!

I have two pages as followed

1. Loading.aspx                      (contain a TextBox1 and a Button1.)

2. PrintL.aspx                         (contain a TextBox2)

Both pages has the same MasterPage.master

When click Button1 on Loading.aspx page, it will PostBackUrl to PrintL.aspx

The question is how can I pass a value from TextBox1 to TextBox2

I try using this but it doesn't work

(code in PrintL.aspx) 

TextBox SourceText = (TextBox)Page.PreviousPage.FindControl("TextBox1");

TextBox2.Text = SourceText.Text;

However it works fine if Loading.aspx doesn't have a master page. Why

Thank you.



Answer this question

CrossPagePostBack

  • Rajesh Choudhary

    I'm have this problem too... and its very fustrating!
    If you've found an answer please share it!


    Thanks!


  • Studlyed

    I'm have this problem too... and its very fustrating. If you've found an answer please share it.

    Thanks,



  • vitia

    I have this exact same issue......... Please advise....

  • mehtan_98

    I know this discussion is old, but for anyone with a similar question, here is the answer as I understand it.

    You can only reference controls on the current page directly. If you are doing a CrossPagePostBack, use the PreviousPage object to reference controls on that page. Otherwise, you can write the values to the Session object and read them at the target page. It's a good idea to remove session values as soon as you are done with them so you don't inadvertently follow the wrong code path on a PostBack.

  • Devesh Wani

    Can someone from this thread please indicate the actual problem you are having In what way does the provided code not work

  • Ademaure

    I am experiencing a seemingly similar problem:

    Page1.aspx (contains hidden fields field1 and field2)

    Page2.aspx (trying to read the values of field1 and field2)

    When I perform a cross-page post from Page1 to Page2 and attempt to read the values of field1 and field to as follows:

    Label1.Text = Request.Form("field1")

    Label2.Text = Request.Form("field2")

    I get empty values in the labels.

    Any ideas


  • CrossPagePostBack