How do I add a dynamic conection to a dynamic Webpart on the same event.

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
 

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
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top