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

Discussion in 'ASP .Net' started by arthernan, Mar 10, 2006.

  1. arthernan

    arthernan Guest

    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
     
    arthernan, Mar 10, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rered

    Conection from dreamwaver

    rered, Mar 2, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    361
    Grant Merwitz
    Mar 2, 2005
  2. Flamadin
    Replies:
    1
    Views:
    1,043
  3. Anuradha

    Db2 Conection

    Anuradha, Jun 1, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    391
    Mark Rae
    Jun 1, 2006
  4. =?Utf-8?B?RG91ZyBTYWxvbW9u?=

    objectdatasource sqldatareader and conection pooling

    =?Utf-8?B?RG91ZyBTYWxvbW9u?=, Nov 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    814
    heinz
    Nov 14, 2006
  5. anars
    Replies:
    0
    Views:
    370
    anars
    Jan 7, 2007
Loading...

Share This Page