Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Master Page - controlling links
Message
 
À
29/10/2008 10:29:21
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01358074
Message ID:
01358097
Vues:
27
>Hi All,
>
>Ok, another master page question. I know I have seen some info on this somewhere but can't remember where. I have a master page that has links to other pages on it. If I am on one of those pages, I want to either hide the link or disable it since we are already on that page. I am not sure if I can get to the master page from the content page or not, but also can I detect which content page is loaded from the master? How can I do this?
>Thanks
>Tim

Yes, you can get to the master page from the content page. Use the Page.Master reference. You may need to cast it if you need to access any custom properties or methods you've defined.
MyMasterPage master = Page.Master as MyMasterPage;

if (master != null)
{
}
You can also use FindControl to find a specific (not nested) control on the master page:
Label label = Page.Master.FindControl("lblSomething") as Label;
The same is true for accessing content from the master page that may be contained in a content page (eg. use FindControl on this.ContentPlaceHolder1, or whatever it's named). You can also just look at the Request.Path (or any of the other various Request paths) to determine which page you're on.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform