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

前端 未结 16 692
一生所求
一生所求 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
    闹比i (楼主)
    2021-02-02 11:07

    I do something similar to this in a project of mine to dynamically attach css files based on the page being loaded. I just get the name of the file from the request:

    this.Request.Url.AbsolutePath
    

    And then extract the file name from there. I'm not sure if this will work if you are doing URL re-writes though.

提交回复
热议问题