PreviousPage null

  • Thread starter Thread starter Luigi Z
  • Start date Start date
L

Luigi Z

Hi all,
in my .NET 2.0 website a have this method in my page:

protected override void OnLoad(EventArgs e)
{
System.Web.UI.Page pag = this.PreviousPage;

}

to retrieve the PreviousPage, but the variable "pag" is always null.

Why this happen?

Maybe because I'm using master pages?

Thanks in advance.
 
Hi,

The previous page can accessed only when You transferred execution from the
previous page to the current. So for example if You use cross-page postback,
or server.transfer on a page to transfer execution to an other, this
property will hold reference to the page You have transferred from. However
in other situations it will be null.

Hope You find this useful.
-Zsolt
 
Mark Rae said:
How are you moving from page to page? If you are using hyperlinks or
Response.Redirect, the PreviousPage property will always be null. To use the
PreviousPage property, you need to use cross-page scripting or
Server.Transfer.

Yes, the problem is that I'm using hyperlinks to move between the pages.

Luigi
 
Hi,

Try using LinkButtons instead of Your hyperlinks, and set the postbackurl to
the desired page, this will make it cross-page.
-Zsolt
 
Back
Top