views:

450

answers:

2

Hi,

Im having the following problem with vb.net asp.net webparts. Im trying to create a static connection between webparts but im running into a problem, namely:

Could not find the connection provider Web Part with ID 'Ucl_Diary_Summary1'

I have the following defined as my iterface:

Public Interface IDiaryPartsProvider

    function Test as String

End Interface

I have the following as my Consumer (UserControl):

Partial Class UsrCtrls_Diary_ucl_DiaryAwaitingReview
    Inherits System.Web.UI.UserControl

    <ConnectionConsumer("Test", "myID")> _
    Public Sub GetTextTransferInterface(ByVal provider As IDiaryPartsProvider)
        Dim a As String = provider.Test()
        UserMsgBox(a.ToString, Me.Page)
    End Sub

End Class

I have the following defined as my Provider (UserControl):

Partial Class UsrCtrls_Diary_Diary_Summary
    Inherits System.Web.UI.UserControl

    Implements IWebPart, IDiaryPartsProvider

    <ConnectionProvider("myID")> _
    Public Function Test() As String Implements IDiaryPartsProvider.Test
        Return "this is a test"
    End Function
End Class

I have my default.aspx as follows:

<%@ Register Src="UsrCtrls/Diary/ucl_Diary_Summary.ascx" TagName="ucl_Diary_Summary"
    TagPrefix="uc4" %>
<%@ Register Src="UsrCtrls/Diary/ucl_DiaryAwaitingReview.ascx" TagName="ucl_DiaryAwaitingReview"
    TagPrefix="uc5" %>

<asp:WebPartManager ID="WebPartManager1" runat="server">
            <StaticConnections>
                <asp:WebPartConnection ID="cnn"
                ConsumerID="Ucl_DiaryAwaitingReview1"
                ProviderID="Ucl_Diary_Summary1"
                />
            </StaticConnections>
        </asp:WebPartManager>

<asp:WebPartZone ID="zoneDiaryTopLeft" runat="server" EmptyZoneText="Add WebPart Here" DragHighlightColor="#454777" HeaderText=" ">

                                    <ZoneTemplate>
                                    <asp:Panel ID="pnl1" runat="server" title="Claims Awaiting Review">
                                    <asp:UpdatePanel ID="udp_TopLeft" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
                                    <ContentTemplate>
                                        <uc5:ucl_DiaryAwaitingReview ID="Ucl_DiaryAwaitingReview1" runat="server" title="Claims Awaiting Review" />
                                        </ContentTemplate>
                                    </asp:UpdatePanel>
                                    </asp:Panel>
                                    </ZoneTemplate>
</asp:WebPartZone>

<asp:WebPartZone ID="zoneDiaryTopRight" runat="server" EmptyZoneText="Add WebPart Here" DragHighlightColor="#454777" HeaderText=" ">
                        <ZoneTemplate>
                        <asp:Panel ID="PNL2" runat="server" title="Diary Summary">
                       <asp:UpdatePanel ID="udp_TopRight" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
                        <ContentTemplate>
                            <uc4:ucl_Diary_Summary ID="Ucl_Diary_Summary1" runat="server" Title="Diary Summary" />
                        </ContentTemplate>
                        </asp:UpdatePanel>
                        </asp:Panel>
                        </ZoneTemplate>
</asp:WebPartZone>

I can only assume its because I have my webparts - usercontrol wrapped in a panel (used for scrolling) and also an updatepanel which I use to refresh, so how do I get it to see the usercontrol?

Thanks in advance.

James.

+1  A: 

I didn't have a chance to look at your message in detail but the issue appears to be with your provider. It should be returning an object that implements the interface used for communication to the consumer (usually a reference to itself).

Check out the following resource for more info:

Introducing ASP.NET Web Part Connections

Rob Windsor
+1  A: 

I found out my problem/solution in the end.

Rob you are correct I needed to pass back an instance of the object implementing the interface but also, you cant reference a User Control for a static connection which is a child of two other controls, namely the panel and update panel. I was doing this all wrong. I changed it so that the update panel is inside the user control rather than on the default page. That way all the specific (web part) components are self contained.

Also, referring back to the original item of returning the instance, I replaced the following:

Public Function Test() As String Implements IDiaryPartsProvider.Test
    Return "this is a test"
End Function

with:

   <ConnectionProvider("myID")> _
Public Function Test() As IDiaryPartsProvider
    Return me
End Function


Public ReadOnly Property Test() As String Implements IDiaryPartsProvider.Test
    Get
        Return "This is a test"
    End Get
End Property

Hope this can help someone!

James.

JamesM
Hi James,Glad I could help.You should mark my response or your follow-up as the answer or the system will continue to show this question as unanswered.
Rob Windsor