Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6381921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:27:23+00:00 2026-05-25T02:27:23+00:00

Now I know this does not make for good design practice, however it is

  • 0

Now I know this does not make for good design practice, however it is legacy code with a bug that needs fixing so I am going to have to live with it.

The scenario is I have a set of nest Master pages (3 deep), call them Base > Template > 2Col. I am working at the 2Col level. As the name suggests the 2Col master page has two content placeholders, MainContent and SideContent.

I have user UserControl in MainContent that needs to reference another UserControl in SideContent.

ContentPlaceHolder ph = (ContentPlaceHolder)this.Page.Master.FindControl("SideContent");
MyUserControl uc = (MyUserControl )ph.FindControl("MyUserControl1");

I am not sure why this doesn’t work, the intellisense when I debug would lead me to think that the ContentPlaceHolder is there, but the first line always returns null?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:27:24+00:00Added an answer on May 25, 2026 at 2:27 am

    Because of the nesting of Master pages you need access the correct master page like so:

    ContentPlaceHolder ph = (ContentPlaceHolder)Parent.Parent.FindControl("SideContent");
    

    Alternatively if you need to find any control on the Page from the Master use the following:

    ContentPlaceHolder ph = (ContentPlaceHolder)FindControl(Page.Master, "SideContent");
    
    ...
    
    private Control FindControl(Control parent, string id)
    {
        foreach (Control child in parent.Controls)
        {
            string childId = string.Empty;
            if (child.ID != null)
            {
                childId = child.ID;
            }
    
            if (childId.ToLower() == id.ToLower())
            {
                return child;
            }
            else
            {
                if (child.HasControls())
                {
                    Control response = FindControl(child, id);
                    if (response != null)
                        return response;
                }
            }
        }
    
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Introduction: Now I know this question could be very broad and it would be
Now, I know this is completely subjective, so please don't flame me. I've never
Ive been tryin to solve this for a long time and now know why
I've asked this same question with Python. Now I like to know if this
Following on from this question , I now want to know how to stop
Now this may seem like a silly question, but I need to know how
I know I can do this: IDateTimeFactory dtf = MockRepository.GenerateStub<IDateTimeFactory>(); dtf.Now = new DateTime();
Now I know that bigint is 2^64; that is, more atoms than there are
I want to make a program that does an order entry system for beverages.
So, I now know what to save from nightly builds . What about when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.