Web Part Minimize

S

Santosh

When I dynamically add Web parts to my code On Minimize event web part
get deleted.
My WebPartZone, WebPartManager is defined in MasterPage
I want to programatically add control to my Web Part.

Code is as follows.

Kindly Help

protected void Page_Load(object sender, EventArgs e)
{
WebPartZone wz =
(WebPartZone)Master.FindControl("WebPartZone1");
// WebPartZone wz2 =
(WebPartZone)Master.FindControl("WebPartZone2");
// string s = wz.WebParts.Count.ToString();
WebPartManager wm =
(WebPartManager)Master.FindControl("WebPartManager1");
Control con = LoadControl("WebUserControl.ascx");
con.ID = "userControl";
GenericWebPart wp = wm.CreateWebPart(con);
wp.ID = "w1";
wp.AllowEdit = true;
if (! IsPostBack )
wm.AddWebPart(wp, wz, 0);

wm.DisplayMode = WebPartManager.DesignDisplayMode;
}
 

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
474,262
Messages
2,571,052
Members
48,769
Latest member
Clifft

Latest Threads

Top