How to create UserControl as webpart at runtime.

G

Guest

I'm adding UserControls as WebPart at runtime to a WebPartZone. This is
working fine but when I add two or more UserControl instances, the
UserControls are overlapping each other i.e. When I add first UserControl it
gets added successfully but when I add another UserControl to the same zone,
this new UserControl overlapps the first UserControl and it gives a confusing
look to the user. Also, the Title area of these webparts shows at different
areas but actual control overlaps each other.

Here is the code I'm using to create and add UserControls as WebPart:


protected void CreateWebPart(string ucName)
{


int index = wpzCycloneOperations.WebParts.Count - 1;

Control uc = this.LoadControl(ucName);
uc.ID = ucName + index.ToString();




GenericWebPart _wp = WebPartManager1.CreateWebPart(uc);
_wp.Title =

" ";
_wp = (

GenericWebPart)WebPartManager1.AddWebPart(_wp, wpzCycloneOperations, index +
2);
_wp.ChromeType =

PartChromeType.None;
_wp.Height =

Unit.Pixel(1);


}

Please help me to solve this issue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top