Name of previous page

  • Thread starter Thread starter David C
  • Start date Start date
D

David C

I want to know what the name of the previous page was in the Page_Load of
the opened page but I cannot find anything in the Page.PreviousPage
properties. How can I know the calling page from a Page_Load event?
Thanks.

David
 
We can get the previous page from the HTTP_REFERER Server Variable
too --BUT-- only if a click event was used to request the opened page.
 
Mark Rae said:
Page.PreviousPage will only be populated if you're doing cross-page
posting:
http://msdn.microsoft.com/en-us/library/ms178139.aspx

Alternatively, you can look at the Request.UrlReferrer property:
http://www.google.co.uk/search?aq=1&oq=Request.Ur&sourceid=chrome&ie=UTF-8&q=request.urlreferrer

However, this cannot be relied on as it will not be available after a
Response.Redirect. Also, if this is a public website, you may find that
your ISP strips this name/value pair out of the Request headers for
(alleged) security reasons...
I am using javascript window.open() to open the page because I want to
control the width and height of the opened page. Does that help? Is there
another way I can do the same with HyperLink control? Thanks.

David
 
If, on the previous page itself, you create a public property that contains
the, at that point, current page's name, you can retreive that on the second
page that you crosspagepostback to by using the
Page.PreviousPage.propertyName syntax. You'll also need to use the
PreviousPageType directive on the second page for this to work.

-Scott
 
Back
Top