newbie: a ContentPlaceHolder question here

J

Jeff

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
 
K

Ken Cox [Microsoft MVP]

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]
 
J

Jeff

Hey

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

Jeff


Ken Cox said:
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]

Jeff said:
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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top