0
votes

Here's some background info:

  • Page 1: Contains a text box
  • Page 2: Contains a label

If I do a Response.Redirect("Page2.aspx") I can easily access the text box on Page1.aspx by using PreviousPage.TextboxRef and assign its value to the label on Page2. No problems here. Everything works as expected.

However, if I do a JS redirect like this:

window.location.href = "Page2.aspx";

The PreviousPage object on Page2 is null. I have tried writing a function that does a "post" instead, but that still results with the same issue.

I also tried checking the Request.UrlReferrer.ToString() value and it is coming back correctly as Page1.aspx.

I'm sure it's something simple, but alas; I'm a noob.

I have searched for a solution with no success, so I'm hoping someone here can help.

1
Thanks! It does make it a lot easier to read ; ) - A. Acevedo
Well, you can't. If you use JavaScript to redirect, PreviousPage will always be null. All the states are lost since they are 2 completely different languages. - VDWWD
I was afraid of that, but I was hoping there was some cool secret way to do it ; ) Thank you for the response. - A. Acevedo

1 Answers

0
votes

Here you can do something like this in javascript where you are setting url.

window.location.href = "Page2.aspx?txt1Value="+document.getElementById('txt1Value').value;

and on other page you can get it using querystring in c#

Label1.Text = Request.QueryString["txt1Value"];