Reference control on nested master page

Master page and nested master pages in an ASP.Net 2.0 are great features to make the site maintainable from the design prospective. Its easy to reference controls on the master page directly from the content pages. But if you have used nested master page, the same approach doesn’t works.  Here is how you can reference control on the nested master page.
Master Page—>Nested Master Page –> Panel on nested master page needs to be referenced from a content page that uses the nested master page (Master–>Nested Master–>Content page).

Find the control on nested master page is like this.

Panel  pnl =  (Panel)this.Master.Master.FindControl("ContentPlaceHolder1").FindControl("pnlMyPanel");

Where  ContentPlaceHolder1 is the id of the content place holder of main master page.

, ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Share to Facebook Share to Twitter Stumble It Share on Tumblr Digg More...