Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Share Data Between Web Parts View modes: 
User avatar
Member
Member
pt - 4/21/2011 10:01:31 AM
   
Share Data Between Web Parts
Hi,
New user here. I'm using a "Latest News" web part to show Events and then using another "Latest News" web part underneath to show News items (both web parts are displayed in a page side bar). (The same web part cannot be used to show a combined list of Events and News items due to client requirements.) My challenge is... if the number of Events is less than a specified number I must add this number to the number of News items to be displayed. For example, 3 Events are to be shown and 3 News items are to be shown. If only 1 Event exists, the number of News items must change to 5. How can I get the number of events and how can I update the number of News items to be shown? (Is something like a ViewState or Session object available? Is my "separate" controls approach correct or should I be developing a custom or "composite" control for this?
Many thanks,
Paul

User avatar
Member
Member
kentico_alleng - 4/21/2011 12:36:47 PM
   
RE:Share Data Between Web Parts
Hi Paul,

Controls and web part intercommunication is being considered for future versions. Unfortunately, for now it is possible only by using URL parameters and full postback or by developing a custom control which contains two or more web parts.

Regards,
Allen Greenhaw

User avatar
Member
Member
pt - 4/22/2011 5:42:59 AM
   
RE:Share Data Between Web Parts
Thank you Allen for the reply and advice. Hopefully you don't mind a few additional questions:

1) Would the custom control I'm developing be something that inherits from the ASP.NET server control, System.Web.UI.Control, or is there a Kentico flavor of this that I can use (including the Kentico repeater web parts)?

2) Is there a method/property that would allow me to get the number of rows/items in the collection of News items within the Kentico latest news web part?

3) I've done some searching on the Kentico site for reference material on custom controls and web parts and haven't found much - is there a link that you can share that's a good reference on developing/modifying existing Kentico controls/web parts?

Thanks again,
Paul

User avatar
Member
Member
kentico_alleng - 4/22/2011 12:06:46 PM
   
RE:Share Data Between Web Parts
Documentation on creating custom controls and web parts can be found in the developer's guide. Some good places to start:

Developing form controls
How to develop inline controls
Developing web parts



This forum post has a discussion on how to count the number of items in a news repeater (or any CMSRepeater):
CMSRepeater Item Count











User avatar
Member
Member
kentico_alleng - 4/22/2011 11:51:25 AM
   
RE:Share Data Between Web Parts
Correction: You can pass some information between web parts, using the RequestStockHelper class.

RequestStockHelper.Add() inserts an item into HttpContext.Current.Items, and then
you can use RequestStockHelper.GetItem() to retrieve the item in the code of another web part.

Regards,

Allen Greenhaw

User avatar
Member
Member
pt - 4/22/2011 4:17:12 PM
   
RE:Share Data Between Web Parts
Thank you Allen. This has been very helpful. I believe this is going to solve my problem.