views:

17

answers:

1

All the Google finds I ran into tell me how to use FindControl to access a control on the master from the content page itself.

However, what I'm trying to do is the opposite. From the master page, I want to reference whichever child page is in the ContentPlaceHolder.

Why you ask. I want the master page to know which tab should be active depending on the content Page currently in the placeholder. This lets me avoid having each page to reference the master page and allow them to change the active tab; that should be the master page's job (if there's a way it can know whom it's enclosing).

Thanks. No rants please.

+2  A: 

If you are looking to get the instance of the executing page class, you can retrieve it from the current HTTP context:

var page = HttpContext.Current.CurrentHandler as Page;

From there, you can navigate the page's control tree, call FindControl(), and so on. Be cautious about page lifecycle, though, as master page events tend to fire before their page event counterparts.

kbrimington
Perfect answer of exactly what I need!
Beemer
And it works beautifully... Thanks a million!!!
Beemer