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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:00:36+00:00 2026-05-28T06:00:36+00:00

I have controls inside a UpdatePanel like this <asp:ScriptManager ID=ScriptManager1 runat=server></asp:ScriptManager> <asp:UpdatePanel ID=UpdatePanel1 runat=server>

  • 0

I have controls inside a UpdatePanel like this

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        Step 1 (Choose a Widget to Manage)<br />
        <asp:DropDownList ID="DropDownWidgetSelection" runat="server"  
            OnSelectedIndexChanged="DropDownWidgetSelection_SelectedIndexChanged" 
            AutoPostBack="True">
        </asp:DropDownList>
        <div id="WidgetAdminControls" runat="server"></div>
    </ContentTemplate>
</asp:UpdatePanel>

When an Item is selected, it will add a new UserControl to WidgetAdminControls
WidgetAdminControls.Controls.Add(widget);

However, when I click on the control is disappers, I assume because the page is rebuilt or somehting and it does not know about the dynamically added UserControl.

How do I fix this problem?

  • 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-28T06:00:37+00:00Added an answer on May 28, 2026 at 6:00 am

    You are correct, the page is rebuilt, thus you must recreate the control tree with every partial or complete postback.

    To accomplish this, you must make your page stateful or include enough information to recreate the control tree with every roundtrip. Every approach has its advantages/disadvantages.

    Stateful

    Most likely a stateful page will use Session; care must be taken not to dump too much data into Session and to cleanup properly (I usually use a manager to wrap Session and manage how many active objects a user can have at once). The upside is that Session (even out of process) is very fast and secure.

    Roundtrip

    This approach uses ViewState, hidden fields, or information in the URL. If information is included with the page, it should be measured in bytes, i.e. it should be extremely small. It is also not immune to tampering.

    The upside is that you really don’t have to do much to make this work, and there is no disposition process needed to cleanup.

    Database

    Alternatively, you could persist your changes to a database with every click and rebuild the tree from the database, but I’m not usually not a fan of this approach unless the click represents a very significant event and the data is complete and validated.

    Very Simple Example

    Here is an example showing the use of Session to maintain a control tree. This should work but it doesn’t account for many things, such as the user opening another copy of the same page in the same session. Managing control trees can get quite complex.

    private List<string> _listOfStrings
    {
       get
       {
         return (List<string>)Session["_listOfStrings"];
       }
       set
       {
         Session["values"] = value;   
       }
    }
    
    protected override OnInit( EventArgs e )
    {
        if( !Page.IsPostback )
        {
            _listOfStrings = new List<string>();
        }
    
        BuildControlTree();
    }
    
    private void BuildControlTree()
    {
       foreach( string s in _listOfStrings )
       {
         // add a control to the control tree
       }
    }
    
    protected void btnAddItem_Click( object sender, EventArgs e )
    {
        _listOfStrings.Add( "some new item" );
    
        // insert the control into the tree
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page setup like so: <ajax:UpdatePanel id=UpdatePanel1 runat=server UpdateMode=Conditional> <ContentTemplate> <asp:TextBox id=TextBox1
I have two updatepanels inside an accordion control, laid out like this: <accordion> <first
I have an ASP.Net CheckBoxList control inside an Ajax UpdatePanel. I will include the
I have a Panel and I am adding controls inside this panel. But there
I have a series of controls on an ASP page. Some are inside an
I have a asp:textbox inside an AJAX updatepanel. My goal is to be able
I have a Repeater with an ASP.NET AJAX 1.0 UpdatePanel inside it. There are
Some ASP.NET controls only permit items of certain types, for example: <uc:MyControl runat=server....> <MyTableTemplate>
I have two UpdatePanels, UpdatePanel1 and UpdatePanel2. I am inside of a server-side event.
I have a menu control inside of an updatepanel. When I hover over a

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.