A
arthernan
If I separate the code into two buttons on a web page it works. One
button creates the webpart and the second creates the connection. But
the minute I move the connection creation code to the web part
creation, I get a webpart does not belong to this page.
I can appreciate how the webparts may not be ready for the connections.
How do I make them ready on the same event? I don't want to have users
clicking two buttons to open two connected webparts.
The following are the separated procedures that do work:
Protected Sub CreateWebParts_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Handles CreateWebParts.Click
Dim _PersonListPart As New myControls.PersonListPart
Dim _PersonSearchPart As New myControls.PersonSearchPart
WebPartManager1.AddWebPart(_PersonSearchPart, Me.WebPartZone2,
0)
WebPartManager1.AddWebPart(_PersonListPart, Me.WebPartZone2, 0)
End Sub
Protected Sub ConnectWebParts_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Handles ConnectWebParts.Click
Dim _PersonSearchPart As MyControls.PersonSearchPart = _
WebPartManager1.WebParts(0)
Dim _PersonListPart As myControls.PersonListPart = _
WebPartManager1.WebParts(1)
Dim provPoint As ProviderConnectionPoint = _
WebPartManager1.GetProviderConnectionPoints(_PersonSearchPart)(0)
Dim consPoint As ConsumerConnectionPoint = _
WebPartManager1.GetConsumerConnectionPoints(_PersonListPart)(0)
WebPartManager1.ConnectWebParts(_PersonSearchPart, provPoint, _
_PersonListPart, consPoint)
End Sub
button creates the webpart and the second creates the connection. But
the minute I move the connection creation code to the web part
creation, I get a webpart does not belong to this page.
I can appreciate how the webparts may not be ready for the connections.
How do I make them ready on the same event? I don't want to have users
clicking two buttons to open two connected webparts.
The following are the separated procedures that do work:
Protected Sub CreateWebParts_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Handles CreateWebParts.Click
Dim _PersonListPart As New myControls.PersonListPart
Dim _PersonSearchPart As New myControls.PersonSearchPart
WebPartManager1.AddWebPart(_PersonSearchPart, Me.WebPartZone2,
0)
WebPartManager1.AddWebPart(_PersonListPart, Me.WebPartZone2, 0)
End Sub
Protected Sub ConnectWebParts_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Handles ConnectWebParts.Click
Dim _PersonSearchPart As MyControls.PersonSearchPart = _
WebPartManager1.WebParts(0)
Dim _PersonListPart As myControls.PersonListPart = _
WebPartManager1.WebParts(1)
Dim provPoint As ProviderConnectionPoint = _
WebPartManager1.GetProviderConnectionPoints(_PersonSearchPart)(0)
Dim consPoint As ConsumerConnectionPoint = _
WebPartManager1.GetConsumerConnectionPoints(_PersonListPart)(0)
WebPartManager1.ConnectWebParts(_PersonSearchPart, provPoint, _
_PersonListPart, consPoint)
End Sub