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

  • Home
  • SEARCH
  • 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 538667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:03:21+00:00 2026-05-13T10:03:21+00:00

I have a user control that needs to load a child control when a

  • 0

I have a user control that needs to load a child control when a button is clicked.
The trouble is that it has to request the control from another class.

So in the button click event, I call the function to get me my control, and add it to the page, like this:

UserControl ctrl = ExampleDataProvider.GetControl(some params...);
myDetailPane.Controls.Add(ctrl);

The GetControl method looks like:

public static UserControl GetControl(some params...)
        {
            ExampleDetailPane ctrl = new ExampleDetailPane();
            ctrl.Value = "12";
            ctrl.Comment = string.Empty;
            return ctrl;
        }

This isn’t working due to the page’s lifecycle – the Page_Load of the child control gets fired and its controls are null.

I kind-of know that my approach is wrong and why, but don’t know the best way to go about fixing it! Could anyone help?

  • 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-13T10:03:21+00:00Added an answer on May 13, 2026 at 10:03 am

    Dynamic controls must be re-created on every postback, this Article is a good link about how to persist dynamic controls and their state.

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

Sidebar

Related Questions

I have an User Control that host another controls like panel, chart controls. Right
I have a user control that has a few public properties, one is an
I have a user control that takes a several seconds to load. Is there
I have a user control that contains a GridView. The GridView has both a
I have a user control that contains multiple controls (CheckBox, Button, Label...). I want
I got a web user control where I have controls that needs to be
I have written a user control that captures some user input and has a
I have application that needs to load local html file if user is offline,
I have a User Control that need load some jquery scripts in client side,
I have a user control that is being integrated to the page on run

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.