Wednesday, April 2, 2008

Setting Title of a dynamic created webpart

My portal adds and deleted webparts dynamically. I was facing difficulty in setting title of dynamically created webparts. Most of the methods somehow did not work. The following did work for me:


Control c = LoadControl(controlName);
c.ID =id;
wp = WebPartManager1.CreateWebPart(c);
this.WebPartManager1.AddWebPart(wp, wz, index);
wz.WebParts[index].Title = title;

No comments: