newbie: a ContentPlaceHolder question here

Discussion in 'ASP .Net' started by Jeff, Jul 23, 2006.

  1. Jeff

    Jeff Guest

    hey

    asp.net 2.0

    I have a ContentPlaceHolder control in my master page. I need a way to
    determine during runtime what is the name of the page being shown in the
    ContentPlaceHolder.

    I ask because if the page shown in the ContentPlaceHolder is "Result.aspx"
    then I should programmatically add some extra menu items to the menu in the
    master page..

    Originally I thought I could use the Control.ID to determine the name of the
    page. But I think that is not the correct approach:
    System.Web.UI.ControlCollection cl = content.Controls;
    foreach (System.Web.UI.Control c in cl)
    {
    if (c.ID == "Result.aspx") {
    }
    }

    Any suggestions?

    Jeff
     
    Jeff, Jul 23, 2006
    #1
    1. Advertisements

  2. Hi Jeff,

    A simpler way to get the name of the current page is

    Request.ServerVariables.Item("Script_Name")

    Is that what you meant?

    Ken
    Microsoft MVP [ASP.NET]
     
    Ken Cox [Microsoft MVP], Jul 23, 2006
    #2
    1. Advertisements

  3. Jeff

    Jeff Guest

    Hey

    Thanks for that tip, it helped me solve this problem!

    Jeff


     
    Jeff, Jul 24, 2006
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.