ASP.net

Access MasterPage from Child Page, FindControl

TAGs: 0 Comment

Posted By: eligeske on in ASP.net

Accessing a Master Page in ASP.Net can seem trivial for someone coming from an open source background. But once you start to understand the Massive helper methods that .NET provides it starts to get a little easier.

There are several different ways of accessing the MasterPage, but for this post I will be covering the FindControl Method and casting it to the correct object to access the properties.

Panel myPanel = (Panel)Master.FindControl("pnlMyPanel");
 myPanel.Attributes["class"] = ""; // clears the class

In the example above I used it to access the <asp:Panel> with the ID of “pnlMyPanel” and change the Attributes["class"] to be empty. Once you use the FindControl to search the Master you must cast what it locates to the correct object. Pretty Simple.

0 Responses to "Access MasterPage from Child Page, FindControl"

"SHARING IS CARING"

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Learning DHTMLX Suite UI

Learn the foundation of the DHTMLX Suite quickly while building a single page application with multiple components in harmony.

Popular post