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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:22:18+00:00 2026-05-22T17:22:18+00:00

Good Afternoon. I have a list of panel that are dynamically created on Page_Load.

  • 0

Good Afternoon.

I have a list of panel that are dynamically created on Page_Load. Controls Are added via the Control.Add(p); method. code Follows

Panel p = new Panel();
p.ID = "cell_" + i + "_" + j;
p.Attributes.Add("runat", "server");
p.TabIndex = -1;
p.Attributes.Add("class", "box");
p.Attributes.Add("onClick", "clicked(this);");
p.Attributes.Add("onKeypress", "changeValue(event, this);");
p.Style.Add(HtmlTextWriterStyle.Top, top + "%");
p.Style.Add(HtmlTextWriterStyle.Left, left + "%");
p.Attributes.Add("Text", value);

PanelList.Add(p);

this block of code is in a for loop and the i, j, left, right, and value variables are altered every loop.

Now, When i call this function BEFORE Page_Load Finishes:

foreach (Control c in clientGrid.Controls)
{
    Response.Write(c.ClientID.ToString());
}

It sucessfully writes all the client ID’s of all the dynamically created panels.

However, When i run the foreach function on postback, the Response.write displays nothing. Its as if asp has forgotten these panels exist!

Now i hear that on Page_Init(), the controls need to be re-rendered!

Im not sure How to do this and after many googles, cant seem to find an answer.

Ive tried using recurtion to iterate through all Page.Controls and pull out the

System.Web.UI.WebControls.Panel

But still no luck 🙁

If my question in unclear, I cant provide more code and details 🙂

Thankyou

Alex

  • 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-22T17:22:19+00:00Added an answer on May 22, 2026 at 5:22 pm

    The dynamically added controls must be re-added to the page upon each postback. I don’t know if this will meet your logical requirements but make sure you add your controls in the page_load method outside of your (!isPostback) condition. Then make sure your logic for writing out the client ids is called after the controls are added to the page.

    If you need to store state information about these controls between postback, you will probably have to use some javascript and hiddenfields.

    All of your event handlers should be called after Page_Load so if you add the controls in the Page_Load, you should be fine. OnPreRender is sometimes useful for this kind of thing. It gets called after Page_Load but before the post back finishes.

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

Sidebar

Related Questions

Good Afternoon, I have a page (category-list.apsx) that uses the Repeater Control method to
Good Afternoon All, I have a wizard control that contains 20 textboxes for part
Good afternoon all, I have a Java applet that I wish to embed on
Good Afternoon, I have a list being generated gradually on the users screen, (right
Good afternoon In Java, I have HashSet which contain list of Object User which
Good Afternoon, I have a html aspx page that has many many div elements.
Good afternoon, I have been working on a dll that can use CORBA to
Good afternoon. I have a Repeater with a ItemTemplate that prints one column with
Good afternoon people's I have built a jquery plugin that I use on my
Good Afternoon All, I have written an SSIS 2005 package that contains a conditional

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.