P
Paal Berggreen
How is a WebPart programmatically added to a WebPartZone, in code-behind?
I would intuitively think that something like this is the way to go:
this.WebPartManager1.Zones["WebPartZone1"].Controls.Add(myPart);
but of course that does not work (WebPartZone does not allow child control),
presumably since the location of the WebParts within the zones etc. are
determined dynamically by the framework, even if the html source places a
specific control in a specific Zone.
So, I want to add a WebPart control to a specific WebPartZone runtime, e.g.
in Page_Load for the page (without having to define the control in the .aspx
design time).
I have played around with various Controls collections, but either they do
not work, or the control is added at the very end of the page, after the
form and body tags :-(
Anyone?
-Paal
I would intuitively think that something like this is the way to go:
this.WebPartManager1.Zones["WebPartZone1"].Controls.Add(myPart);
but of course that does not work (WebPartZone does not allow child control),
presumably since the location of the WebParts within the zones etc. are
determined dynamically by the framework, even if the html source places a
specific control in a specific Zone.
So, I want to add a WebPart control to a specific WebPartZone runtime, e.g.
in Page_Load for the page (without having to define the control in the .aspx
design time).
I have played around with various Controls collections, but either they do
not work, or the control is added at the very end of the page, after the
form and body tags :-(
Anyone?
-Paal