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 7800409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:37:39+00:00 2026-06-02T00:37:39+00:00

I have Main.Master, an inner master page Inner.Master, and abc.aspx. In Inner.Master I have

  • 0

I have Main.Master, an inner master page Inner.Master, and abc.aspx. In Inner.Master I have a dropdownlist ddlChildren which I populate on Inner.Master page load.

I would like to, on loading page abc.aspx, I get access to ddlChildren from its master page, Inner.Master:

int x = Int32.Parse(((DropDownList)this.Parent.FindControl("ddlChildren")).SelectedValue);

I am doing this on page load of abc.aspx. The problem is this control is not found. I think this happens becuase the control is not even loaded yet in Inner.Master, because when I do:

this.Parent.Controls.Count

at debugging, I only have 1 control for Inner.Master, which its Main.Master.

I then tried to call ddlChildren onPreRender, but the same Happens.

According to http://msdn.microsoft.com/en-us/library/ms178472.aspx, controls are loaded at pre render, but the on pre render of inner master is called AFTER abc.aspx. So can I do this at another page stage?

Or am I completely off track?

  • 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-06-02T00:37:41+00:00Added an answer on June 2, 2026 at 12:37 am

    Visual breakdown of the lifecycle, including master pages.

    OK, I think there is more going on here.

    First of all FindControl isn’t recursive, unless what you are looking for is a direct child of the object in question, you won’t find it.

    You’ll need a function something like this (not tested, but I’ve written something like it before):

    private WebControl FindControlRecursive(WebControl parentControl, string controlId)
    {
        if( !parentControl.Controls.Any())
            return null;
    
        var foundControl = parentControl.FindControl(controlId);
    
        if(foundControl == null)
        {
            foreach(child in parentControl.Controls)
            {
                var foundChild = FindControlRecursive(child, controlId);
    
                if(foundChild != null)
                    return foundChild;    
            }
        }
    
        return foundControl;
    }
    

    Second, you’re assuming Parent of your page is the master page. This may not be true. Try Page.MasterPage detailed here.

    So, to conclude, try this:

    var dropDown = (DropDownList)FindControlRecursive(Page.MasterPage, "ddlChildren");
    

    One more thing. It’s usually good to consider that if you find yourself accessing controls that exist in a level above your current Page scope, you may want to rethink your design.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following placeholder in my main master page. I would like to
I have a main page which looks like: <%@ Page Title= Language=C# MasterPageFile=~/Views/Shared/Site.Master Inherits=System.Web.Mvc.ViewPage
I have a page called Default.aspx which inherits from a master page called Main.master.
I have a radMenu on the main site.master form which shows on a page.
I have my main view like this: <%@ Page Title= Language=C# MasterPageFile=~/Views/Shared/Site.Master Inherits=System.Web.Mvc.ViewPage %>
I have a like button on my main page (master page in asp.net). I
I have 2 master pages that are nested.this is main master page code for
I have a main master page, say MasterPageMain, and a couple of folders with
I have a main folder Abc which has about 800 sub-folders. Each of these
I have an ASP.NET / C# application in which the Master Page contain the

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.