When a page loads, in order to get the name of the page that sent you there, all you need to use is:
Request.UrlReferrer.ToString();
You can create a global variable to hold it:
string sReferrer = "";
Then, in the Page_Load event, assign it:
if (!Page.IsPostback)
{
sReferrer = Request.UrlReferrer.ToString();
}
Or, you can put it in ViewState at that time:
if (!Page.IsPostback)
{
ViewState("Referrer") = Request.UrlReferrer.ToString();
}
From there, on out, within that page, you can use either the variable, or ViewState, within that page as a link, or whatever you need it for.Source: https://www.nilebits.com/blog/2008/01/get-referring-page-page-load-event-asp-dot-net/
No comments:
Post a Comment