R
ryan.mclean
Hi all, I am dynamically making the connection between two webparts
when the consumer is added like so:
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
Dim wpGif, wpGroupSelector As WebParts.WebPart
Dim objWpManager As WebParts.WebPartManager =
CType(Page.Master.FindControl("wpmMain"), WebParts.WebPartManager)
Dim objPartCollection As WebParts.WebPartCollection =
objWpManager.WebParts
Dim objPart As WebParts.WebPart
Dim cpGroupSelector As WebParts.ProviderConnectionPoint
Dim cpGif As WebParts.ConsumerConnectionPoint
If ((Page.IsPostBack _
AndAlso (Request.Form("__EVENTARGUMENT") = "add" _
And Request.Form("__EVENTTARGET").IndexOf("czMain")
) Then
For Each objPart In objPartCollection
If (objPart.AllowConnect) Then
If (objPart.Title = "Group Selector") Then
wpGroupSelector = objPart
ElseIf (objPart.Title = "GIFs") Then
wpGif = objPart
End If
End If
Next
If (Not IsNothing(wpGroupSelector)) Then
cpGroupSelector =
objWpManager.GetProviderConnectionPoints(wpGroupSelector)(0)
End If
If (Not IsNothing(wpGif)) Then
cpGif =
objWpManager.GetConsumerConnectionPoints(wpGif)(0)
End If
If (Not IsNothing(cpGroupSelector) And Not IsNothing(wpGif)
_
AndAlso
objWpManager.CanConnectWebParts(wpGroupSelector, cpGroupSelector,
wpGif, cpGif)) Then
objWpManager.ConnectWebParts(wpGroupSelector,
cpGroupSelector, wpGif, cpGif)
End If
End If
End Sub
I know I am not showing all the code, but from what I have listed, can
anyone help me out. What is the deal? In the page_init the controls
don't exist, and in the page_prerender it's too late to connect them. I
am so close
Thank you for any help you can offer,
Ryan
when the consumer is added like so:
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
Dim wpGif, wpGroupSelector As WebParts.WebPart
Dim objWpManager As WebParts.WebPartManager =
CType(Page.Master.FindControl("wpmMain"), WebParts.WebPartManager)
Dim objPartCollection As WebParts.WebPartCollection =
objWpManager.WebParts
Dim objPart As WebParts.WebPart
Dim cpGroupSelector As WebParts.ProviderConnectionPoint
Dim cpGif As WebParts.ConsumerConnectionPoint
If ((Page.IsPostBack _
AndAlso (Request.Form("__EVENTARGUMENT") = "add" _
And Request.Form("__EVENTTARGET").IndexOf("czMain")
Or Not Page.IsPostBack) _-1) _
) Then
For Each objPart In objPartCollection
If (objPart.AllowConnect) Then
If (objPart.Title = "Group Selector") Then
wpGroupSelector = objPart
ElseIf (objPart.Title = "GIFs") Then
wpGif = objPart
End If
End If
Next
If (Not IsNothing(wpGroupSelector)) Then
cpGroupSelector =
objWpManager.GetProviderConnectionPoints(wpGroupSelector)(0)
End If
If (Not IsNothing(wpGif)) Then
cpGif =
objWpManager.GetConsumerConnectionPoints(wpGif)(0)
End If
If (Not IsNothing(cpGroupSelector) And Not IsNothing(wpGif)
_
AndAlso
objWpManager.CanConnectWebParts(wpGroupSelector, cpGroupSelector,
wpGif, cpGif)) Then
objWpManager.ConnectWebParts(wpGroupSelector,
cpGroupSelector, wpGif, cpGif)
End If
End If
End Sub
I know I am not showing all the code, but from what I have listed, can
anyone help me out. What is the deal? In the page_init the controls
don't exist, and in the page_prerender it's too late to connect them. I
am so close
Thank you for any help you can offer,
Ryan