How to determine which Child Page is being displayed from Master Page?

jinsungy picture jinsungy · Nov 6, 2008 · Viewed 43.7k times · Source

I'm writing code on the master page, and I need to know which child (content) page is being displayed. How can I do this programmatically?

Answer

Todd H. picture Todd H. · Jul 9, 2010

I use this:

string pageName = this.ContentPlaceHolder1.Page.GetType().FullName;

It retuns the class name in this format "ASP.default_aspx", but I find that easy to parse for most purposes.

Hope that helps!