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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:07:46+00:00 2026-06-06T18:07:46+00:00

I just have a few questions about programmatically adding controls in aspx . After

  • 0

I just have a few questions about programmatically adding controls in aspx. After doing some research I just want to be sure I understand this correctly.

When you try to add controls programmatically you’re supposed to do this in a certain phase of the page life cycle.

  1. Is the latest you can programmatically create and add controls is in the page_load?

  2. Is it the best practice to create the controls in the initialization phase and is it because this is before the view state gets loaded?

  3. Do you have to keep re-creating the controls upon each post back? Or is there a way to create it once and have it be persistent?

  4. If you change any controls in the onInit phase that exists in the view state will it be replaced automatically when the view state gets loaded?

  5. Does ContentTemplateContainer.Controls.Add(...) add child controls? For example if you try to add a table that is filled with gridviews filled with buttons will there be a partial post back when one of those buttons is clicked? If not how are you supposed to add child controls to the UpdatePanel?

That is all the questions I can think up for now. Any clarification you guys can give me would be great!

  • 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-06T18:07:47+00:00Added an answer on June 6, 2026 at 6:07 pm

    Assuming you’re talking about webforms, and not mvc, you can add new dynamic controls at any phase of the lifecycle. However, it’s important to remember that every time you have a postback (including any server-side event) you are working with a different instance of your page than the one to which you first added your dynamic controls, because you are now preparing a response for a different http request. Once you understand that clearly, everything else starts to make a lot more sense.

    So you want to add a control to the page in response to a button click. You can safely do that in the button’s click event, which is very late in the page life cycle. But now the user does something to trigger another post back. At this point, you are working with a different instance of the page class than you had before. You must add the dynamic control to the page again if you want it to still be on the page after the postback completes. If you also want to use the ViewState for this control, you must do this before (not during) the Page_Load event. The most common place to do this is in Page_Init.

    I think that covers most of your points.

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

Sidebar

Related Questions

I have a few quick questions about the iPhone software development. I did some
I just have a few general questions about keeping code clean and readable. 1)
I have a few questions about security using PHP, I dont want to use
I've been going through some JavaFX tutorials and I have a few questions about
Ok, I have asked a few questions about different facets of trying to accomplish
I have a few questions about boost::regex: I tried an example below. 1) What
I have a few questions about CoreLocation and GPS. First, what method in core
I have few questions about this code: <?php $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv =
Hey everyone, I have a few questions about the iAd platform. I'm not yet
Just a few questions about reverse proxies and performance. Will there be an effect

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.