Hi,
I don't think the above article is what You are after. The concept of creating webparts / webzones from code behind is as follows:
1. You need to instantiate a WebPartManager either declaratively in your markup or in code behind:
Dim partManager As New WebParts.WebPartManager()
partManager.Personalizatio
...
2. Put things in design mode:
Dim mode As WebParts.WebPartDisplayMod
partManager.DisplayMode = mode
...
3. Add zones and parts according to some logic:
Dim numZones As Integer = CInt(Session("numWebZones"
Dim numParts As Integer = CInt(Session("numWebParts"
Dim i As Integer = 0
Dim j As Integer = 0
Do While i < numZones
Dim zone As New WebParts.WebPartZone()
zone.ID = "WebPartZone" & i.ToString()
Do While j < numParts
Dim literal As New LiteralControl("This is webpart " & j.ToString() & " in zone " & i.ToString() & ".")
literal.ID = "WebPart" & i.ToString() & j.ToString()
partManager.AddWebPart(par
j += 1
Loop
j = 0
phZones.Controls.Add(zone)
i += 1
Loop
4. Enjoy!
/Carl.
Main Topics
Browse All Topics





by: deepaknetPosted on 2009-07-09 at 04:16:05ID: 24812388
Check this out http://www.devasp.net/net/ articles/d isplay/308 .html