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;
}
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;
}