How can i add new panel at run time in asp.net

asp.net, c#

Solution

If it is something that you plan on reusing, I'd suggest you utilize a user control for this. You can them simply add a new instance of the control on your page.

A few things worth looking into:

- https://web.archive.org/web/20210707024005/http://aspnet.4guysfromrolla.com/articles/081402-1.aspx

- http://aspalliance.com/565

- http://msdn.microsoft.com/en-us/library/c0az2h86.aspx

If you wanted to accomplish this with a postback to the page, add this to your event...

//MyControl = Custom User Control
var myControl =  (MyControl) Page.LoadControl("MyControl.ascx"); 
this.ControlContainer.Controls.Add(myControl);

Problem

I am working on an asp.net web application where I have predefined panel in my project with CSS. Now i want to create another panel with same design and CSS at run time at multiple times. I have a button control when i will click that button it will add another panel. Please help me to add another panel with same criteria.

Original source