[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Nested MasterPage FindControl

Posted on 2007-08-08
3
Medium Priority
?
1,146 Views
Last Modified: 2008-01-09
I have a nested masterpage setup and I am having trouble finding a panel control I need access to.

MasterPage1:
--------------------------------------------------------------------------------------------------------------------------------
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="HTG.master.cs" Inherits="MasterPage" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> </title>

</head>
<body>
<form id="form1" runat="server">          
<asp:contentplaceholder id="ContentPlaceHolderMain" runat="server"></asp:contentplaceholder>
</form>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------------------

MasterPage 2:
--------------------------------------------------------------------------------------------------------------------------------
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="APP.master.cs" Inherits="PBE.MasterPage" MasterPageFile="~/HTG.master" %>

<asp:Content ID="ContentMain" ContentPlaceHolderID="ContentPlaceHolderMain" runat="Server">

<asp:Panel ID="PanelINeedAccessTo" runat="server">
TEST
</asp:Panel>
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                    </asp:ContentPlaceHolder>
</asp:Content>
-------------------------------------------------------------------------------------------------------------------------------

I need to be able to access PanelINeedAccessTo from any page loading into ContentPlaceHolder1&

I have tried doing a find control on the ContentMain ContentPlaceHolder:
..
            ContentPlaceHolder myContentPlaceHolder = new ContentPlaceHolder();
            myContentPlaceHolder = (ContentPlaceHolder)(Master.FindControl("ContentMain"));
..
Returns null&

Please help!

Nugs
0
Comment
Question by:Nugs
  • 2
3 Comments
 
LVL 8

Expert Comment

by:sabeesh
ID: 19658842
try like this

myMasterPage myMaster = (myMasterPage)this.Master;
ContentPlaceHolder myContentPlaceHolder = myMaster.FindControl("myContentPlaceHolder ") as ContentPlaceHolder ;
myContentPlaceHolder = (ContentPlaceHolder)(Master.FindControl("ContentMain"));
0
 
LVL 8

Accepted Solution

by:
sabeesh earned 1500 total points
ID: 19658846
0
 
LVL 2

Author Comment

by:Nugs
ID: 19658891
Solution:

            ContentPlaceHolder myContent = new ContentPlaceHolder();
            myContent = (ContentPlaceHolder)(Page.Master.Master.FindControl("ContentPlaceHolderMain"));

            Panel myPanel = new Panel();
            myPanel = (Panel)(myContent.FindControl("PanelINeedAccessTo"));

Thanks for the input...

Much Appreciated

Nugs
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question