Najam Sikander Awan

covering web stack along with microsoft technologies

How to Get Pagename of Itself

| Comments

 If you want to display the filename or page name of the current displaying page just use these two lines and it will show only the filename like default.aspx, najam.aspx or indexas.aspx no matter it these pages are located deep into your site structure.

1
string pagename = System.IO.Path.GetFileName(Request.ServerVariables["SCRIPT_NAME"]); Response.Write(pagename);

Enjoy coding

Najam Sikander Awan

Comments