CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.web_parts_and_personalization Tags:
Item Type: NewsGroup Date Entered: 6/5/2007 7:53:10 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 9 Views: 91 Favorited: 0 Favorite
10 Items, 1 Pages 1 |< << Go >> >|
WolfyUK
Asp.Net User
Multiple Web Part consumer connection points6/5/2007 7:53:10 AM

0

Hello,

I can't seem to find any information on how best to implement multiple connections on a consumer web part and was wondering if anyone could point me in the right direction.

I have three web parts: two containing grids of data (the providers) and one containing item detail (the consumer). All of the web parts implement a known interface to enable the connections, and the AllowsMultipleConnections attribute is set to 'true' on the consumer connection point. The desired behaviour is that when an item is selected in EITHER of the grids of data, the information is correctly retrieved and displayed in the connected item detail web part.

Both providers implement their connections (in C#) along the following lines:

        [System.Web.UI.WebControls.WebParts.ConnectionProvider("Provides ML Object", "ProviderWebPartMLObjectProvider")]
public Controls.IMLObject IMLObjectProvider()
{
return this;
}
and the ConsumerWebPart consumer is something like:
 
        [System.Web.UI.WebControls.WebParts.ConnectionConsumer("IMLObject Consumer","ConsumerWebPartMLObjectConsumer",AllowsMultipleConnections=true)]
public void IMLObjectConsumer(Controls.IMLObject MLObject)
{
if (MLObject != null)
{
SomeUniqueCode = MLObject.UniqueCode;
}
else
{
// throw some exception
}
}
 
I was originally connecting the web parts in the codebehind but have since moved the declarations into the WebPartManager as follows:
 
        <asp:WebPartManager ID="WebPartManager" runat="server">
<StaticConnections>
<asp:WebPartConnection ID="ThisConnection" ConsumerID="ConsumerWebPart" ConsumerConnectionPointID="MLObjectConsumer" ProviderID="ProviderWebPart" ProviderConnectionPointID="ProviderWebPartEntityProvider"></asp:WebPartConnection>
</StaticConnections>
</asp:WebPartManager>
 
The setup above works fine for the single connection, but if I try to add another <asp:WebPartConnection> to connect the secondary provider with the same consumer, only the 'last' connection specified actually connects properly, populating the desired data. Strangely enough, analysing the execution order in the page's trace, I can see that the 'first' connection's provider is called, followed by TWO consumptions by the consumer, even though the data actually retrieved is from the 'last' provider in the StaticConnections list.

I hope the above makes sense, as typing out the problem long-hand doesn't really seem to to me! Any pointers?

Thanks,

Marc
Nai-Dong Jin -
Asp.Net User
Re: Multiple Web Part consumer connection points6/6/2007 8:07:34 AM

0

Hi,

From your code, i haven't found the intermediate webpart's code. Suppose we have three web part. A,B and C. Web part A providing data to Web Part B and web part B provides data to Web Part C.  The data passed to web part C relies on the data that has first passed from A to B. Is that you want to achieve? So just regard the WebPart A as provider while WebPart C as consumer and WebPart B is both provider and consumer. and finally declare your webpart connection relationship in static connections node.

Thanks.


Sincerely,
Michael Jin.
Microsoft Online Community Support

?Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ?
WolfyUK
Asp.Net User
Re: Multiple Web Part consumer connection points6/6/2007 11:53:41 AM

0

Hi,

I do not have an intermediate web part. The scenario is more like A and B as two independent providers, with C as a consumer who may expect the provider interface from either A or B at run time:

A => C   or   B => C

not

A => B => C

Thanks,

Marc
 

Nai-Dong Jin -
Asp.Net User
Re: Multiple Web Part consumer connection points6/7/2007 3:20:35 AM

0

Hi,

In your case, WebPart C has two Providers. That's not supported.

Thanks.


Sincerely,
Michael Jin.
Microsoft Online Community Support

?Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ?
WolfyUK
Asp.Net User
Re: Multiple Web Part consumer connection points6/7/2007 8:02:23 AM

0

 That's interesting... do you know what the option to set AllowsMultipleConnections=true on the ConnectionConsumer is for then?

Nai-Dong Jin -
Asp.Net User
Re: Multiple Web Part consumer connection points6/7/2007 9:14:41 AM

0

Hi,

In one page, multiple connections can be existed. One provider can pass values to multiple consumers but one consumer only can get values from one provider. 

Thanks.


Sincerely,
Michael Jin.
Microsoft Online Community Support

?Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ?
apollo_gonzo
Asp.Net User
Re: Multiple Web Part consumer connection points6/19/2007 9:02:03 PM

0

This is my exact situation any pointers how I can achive this?  Again I want to achieve what you have descripbed.

Nai-Dong Jin - MSFT:

Hi,

From your code, i haven't found the intermediate webpart's code. Suppose we have three web part. A,B and C. Web part A providing data to Web Part B and web part B provides data to Web Part C.  The data passed to web part C relies on the data that has first passed from A to B. Is that you want to achieve? So just regard the WebPart A as provider while WebPart C as consumer and WebPart B is both provider and consumer. and finally declare your webpart connection relationship in static connections node.

Thanks.

adshead
Asp.Net User
Re: Multiple Web Part consumer connection points6/27/2007 3:38:02 PM

0

Actually, a web part can consume data from two seperate providers because I am doing exactly that in my project by using the AllowsMultipleConnections=true attribute on the ConnectionConsumer method of the web part.  If you read the MSDN documentation it states "A consumer control by *default* can connect to only one provider at a time" which essentially means the AllowMultipleConnections attribute is false by default. Set it to true and it *should* work. I say should because I have noticed some odd behaviour at times.

I have a scenario where two seperate web parts (A and B) can independently provide data to another web part (C) which in turn can provide data to web part (D).  I have all this working now but I have a hunch that the order in which those connections are initially defined *seems* to have some effect on the order in which the provider methods fire for the different web parts?  My scenario is in a Sharepoint environment (which is essentially ASP.NET) and I manually connect up my web parts at run time using the context menus on the web parts themselves. 

I have noticed that if I connect my web parts in reverse order - i.e connect C to D then connect A and B to C then web part D tries to pull data from web part C before C has had a chance to pull data from either A or B.

I have never been able to prove this for sure because sometimes when I purposely connect things in the reverse order it still seems to work - so I was wondering whether the order in which web parts are added to a page plays some part in deciding the order in which connections events get fired at run time??

I would love to have a definitive answer for this because at the moment I am considering redesigining my web parts so that they work in a manner that does not require them to be "chain-linked"

 

WolfyUK
Asp.Net User
Re: Multiple Web Part consumer connection points6/28/2007 8:12:30 AM

0

It's interesting that you managed to get this to work, seeing as some of the posts above say it's not possible!

I have been in contact with our Microsoft rep who has come up with a neat solution that dynamically adds/removes the connection interface depending on the 'active' provider at run time, but this only seems viable for static connections. Like you, I have now moved over to allowing the user to connect the parts themselves at run time.

The behaviour you (and I) are experiencing does seem rather odd. It seems as though the multiple providers stuff is-work-in progress in ASP.NET 2.0, and even our rep said that the way it's worded in the MSDN documentation makes it seem like this will be a future extension (although the 'Orcas' documentation is identical). 

Marc 

joeyv9
Asp.Net User
Re: Multiple Web Part consumer connection points1/8/2008 7:51:06 PM

0

Wow.

What happened to interface based programming?  There's a consumer web part that can accept an interface (method) but can only really accept one provider when there are multiple providers that implement the interface that the consuming webpart accepts.

Is this for real?


-
Joey
10 Items, 1 Pages 1 |< << Go >> >|


Free Download:




   
  Privacy | Contact Us
All Times Are GMT