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

前端 未结 16 912
一生所求
一生所求 2021-02-02 10:26

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?

16条回答
  •  萌比男神i
    2021-02-02 11:04

    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!

提交回复
热议问题