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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:08:50+00:00 2026-05-18T12:08:50+00:00

I have a UserControl A that has to be loaded first and after that

  • 0

I have a UserControl A that has to be loaded first and after that completes loading, I need to load a UserControl B.

I prefer to add both these user controls on the page at compile time (would like to avoid dynamic loading if possible).

  • If I add user controls on the page at compile time and set visible to false for User Control B, does it still execute the B’s code behind? I can then set the visibility to true after loading User Control A
  • Should I be using events/delegates for notifying the completion of loading User Control A?
  • 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-18T12:08:50+00:00Added an answer on May 18, 2026 at 12:08 pm

    Don’t load everything in the page event in control b, just put a method on control b to be called. Then add an event to control a which the page consumes, when the event is raised, call the load method on control b.

    Edit: SampleCode

    Ok so for example, create

    • a ASPX page
    • 2x user controls

    Put both user controls into the aspx page.

        <cc:control1 runat="server" id="control_one" />
        <cc:control2 runat="server" id="control_two" />
    

    Then in control 1, create a delegate and event.

        public delegate void MyCustomEvent (EventArgs args);
        public event MyCustomEvent MyEvent;
    
        protected void Page_Load(object sender, EventArgs e)
        {
            MyEvent(e);
        }
    

    So I have the event raised on page load. So you would have your logic in there thats required, when your done, calls MyEvent event.

    In the page you want to add a handler for that event so when it’s called you can do something with it.

        protected override void OnInit(EventArgs e)
        {
            control_one.MyEvent += new WebUserControl1.MyCustomEvent(control_one_MyEvent);
            base.OnInit(e);
        }
    
        void control_one_MyEvent(EventArgs args)
        {
            control_two.MyCustomLoad();
        }
    

    So when the page is initialized I add the event handler. In the event handler I call a custom method on the second control to load stuff.

    Then in the second control I have:

        public void MyCustomLoad()
        {
            //Stuff only loaded when event is raised and calls this method.
        }
    

    So this allows control 1 to load something, say it’s done, when the page knows it’s done, it can tell control 2 to do something.

    Edit: After discussing this with a friend I’ll explain what I mean by controlling the order.

    You cannot control the order of page-life-cycle events. i.e: You can’t have Control A, run through all it’s page-life-cycle events, then once it’s done, have Control B run through all it’s page-life-cycle events.

    If you do-away with the page life cycle, you can do a degree, as my example above shows, create a way of controlling the order in which the controls are rendered. By raising an event(s) at certain points when Control A is finished, you can tell Control B to do something.

    The intermediate between the two controls is the page which handles the events raised by Control A which calls a method on Control B. You (well you can hack around to do it) can’t specifically make Control A tell Control B to do something because that creates a direct dependency between the two controls which is bad.

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

Sidebar

Related Questions

I have a usercontrol that has several public properties. These properties automatically show up
I have a UserControl that has a BaseClass object as a public member. Right
I have created a UserControl that has a ListView in it. The ListView is
I have created a UserControl that has 3 panels. What I what to do
I have a Page that has a single instance of a UserControl that itself
I have a UserControl in my Asp.net project that has a public property. I
Suppose I have a UserControl whose DataContext is set to an object that has
I have a TabControl that has four tabs: <TabControl> <TabItem><TextBox/></TabItem> <TabItem><UserControl/></TabItem> <TabItem><Label/></TabItem> <TabItem><Image/></TabItem> </TabControl>
I have a usercontrol that has a popup that displays another usercontrol when the
I have a mvvm(model view viewmodel) silverlight application that has several views that need

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.