PreviousPage null

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.
 
M

miher

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
 
L

Luigi Z

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
 
M

miher

Hi,

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

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

Top