Search content within the blog

Thursday, November 13, 2008

Obtaining the name of the page viewed or been coded from code-behind

string PageName = null;
if (Request.UrlReferrer != null)
{
Int32 lenStart = Request.UrlReferrer.AbsolutePath.LastIndexOf("/") + 1;
Int32 lenRequired = Request.UrlReferrer.AbsolutePath.Length - lenStart;
PageName = Request.UrlReferrer.AbsolutePath.Substring(lenStart, lenRequired);
Response.Write(PageName .trim());
}

No comments:

Post a Comment