How to retrieve the current page's file name from Master Page?

Last post 08-26-2008 12:24 PM by bullpit. 4 replies.

Sort Posts:

  • How to retrieve the current page's file name from Master Page?

    08-26-2008, 12:12 PM
    • Contributor
      3,377 point Contributor
    • mychucky
    • Member since 03-20-2006, 9:01 PM
    • Posts 2,517
    I like to put some code in the Master Page to retrieve the currently displayed page's file name. Is this possible? I want to display different blurb for different page based on their file name and I wanted to do it from the Master Page so I don't have to copy the code and pasted to all of the child pages.
  • Re: How to retrieve the current page's file name from Master Page?

    08-26-2008, 12:13 PM
    Answer
    • All-Star
      20,949 point All-Star
    • bullpit
    • Member since 06-29-2006, 11:59 AM
    • Posts 4,631

    I just posted this in another thread. See if this gives you what you want...

    System.IO.Path.GetFileName(HttpContext.Current.Request.FilePath)

  • Re: How to retrieve the current page's file name from Master Page?

    08-26-2008, 12:18 PM
    • All-Star
      20,949 point All-Star
    • bullpit
    • Member since 06-29-2006, 11:59 AM
    • Posts 4,631

    I didn't even realize that the other thread that I posted to was also yours...

  • Re: How to retrieve the current page's file name from Master Page?

    08-26-2008, 12:22 PM
    • Contributor
      3,377 point Contributor
    • mychucky
    • Member since 03-20-2006, 9:01 PM
    • Posts 2,517

     Thanks, Bullpit. I started this thread because I thought doing it from the master page is different than from the child page. I didn't realize your solution works from the master page too. Again, thank you.

  • Re: How to retrieve the current page's file name from Master Page?

    08-26-2008, 12:24 PM
    • All-Star
      20,949 point All-Star
    • bullpit
    • Member since 06-29-2006, 11:59 AM
    • Posts 4,631

    You are welcome.

Page 1 of 1 (5 items)