Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Web Part Property Access View modes: 
User avatar
Member
Member
lee.diggins-ddiworld - 3/26/2010 9:36:33 AM
   
Web Part Property Access
Hi

I have a need to retrieve the property value from a web part in a page template and use its value in the code-behind of another custom web part.

Any pointers and advice would be greatly appreciated.

Many thanks,

Lee

User avatar
Member
Member
TonyG - 3/26/2010 10:40:27 AM
   
RE:Web Part Property Access
You could load it into session or retrieve it from the database..

I don't think web parts have the ability to talk to each other.

User avatar
Member
Member
sean.kinley-techfringe - 3/26/2010 3:30:11 PM
   
RE:Web Part Property Access
I asked a similar question back in February. This is the response I got:

You can put both web parts into one user control and ensure binding in code-behind of this user control or you can also put dropdown list and control that display the results into one web part. Alternatively you can pass value selected in dropdownlist to page with second web part in query string and use query macro to set the value into property of second web part (or read and set query string value in code-behind of second web part). We use similar approach with Search Box and Search Results web parts

User avatar
Member
Member
DiggaTheWolf - 3/29/2010 1:45:14 AM
   
RE:Web Part Property Access
Hi

Many thanks for your replies.

Neither solution would work for me due to the page layout and the function of the second custom web part.

I have the following situation:

1. First web part contains the page title
2. Second web part is an 'Email this Page' link which has an event which loads an Ajax ModalPopup and form for completion of details.

The page title (web part 1) and friendly URL's are presented to the user in a ModalPopup and therefore I need to capture both values during Page_Load. I've sorted the URL using URLRewriter, so not a problem there, it's just this page title ( header text) issue. Don't ask me about the page title meta tag, apparently I cannot use this due to the way the title is constructed due to SEO. :-(

I'll keep bashing away at this and if come across a solution I'll post back here.

Again, many thanks for taking the time to respond.

Lee

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 3/29/2010 9:18:50 AM
   
RE:Web Part Property Access
Hello,

you could store the page title in the document type properties (you would fill out the value on Form tab) or you could store the value in Editable region web part and retrieve it like here: http://devnet.kentico.com/docs/devguide/selecting_nodes.htm

Best regards,
Helena Grulichova

User avatar
Member
Member
DiggaTheWolf - 3/29/2010 10:18:00 AM
   
RE:Web Part Property Access
Hi Helena

This is excellent, especially the Editable region piece which is the approach I would want to take.

Is there a Get Current Node method available, if not can you explain how I find out where I am currently? Also how would I handle Culture? Is this based on the current document or user?

Many thanks

User avatar
Member
Member
DiggaTheWolf - 3/30/2010 1:26:55 AM
   
RE:Web Part Property Access
Thanks to the pointer from Helena I was able to retrieve the data I was after. Ithink I've got this right with the following code:

    #region private void GetPageData()
private void GetPageData()
{
UserInfo ui = UserInfoProvider.GetUserInfo(CMSContext.CurrentUser.UserName);
CMS.TreeEngine.TreeProvider tree = new TreeProvider(ui);
CMS.TreeEngine.TreeNode node = tree.SelectSingleNode(
CMSContext.CurrentSite.SiteName,
CMSContext.CurrentDocument.NodeAliasPath,
CMSContext.CurrentDocument.DocumentCulture);

if (node != null)
{
if (node.DocumentContent.EditableWebParts[targetWebPartName] == null)
{
pageTitle = this.Page.Title;
}
else
{
pageTitle = (string)node.DocumentContent.EditableWebParts[targetWebPartName];
}
}
else
{
pageTitle = this.Page.Title;
}

pageUrl = Request.Url.Scheme + "://" + Request.Url.Host + URLRewriter.CurrentURL;
}
#endregion

Many thanks for the support Tony, Sean and Helena. This is my first attempt at working with Kentico CMS and your responses are very much appreciated.

Also, if there's something not quite right in the code above, please let me know.

Regards,
Lee

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 4/1/2010 5:06:24 AM
   
RE:Web Part Property Access
Hi Lee,

you could also use the PageInfo object of CMSContext class instead of selecting a node of current document.
CMSContext.CurrentPageInfo.EditableRegions[targetWebPartName]

(It cannot set the regions but read.)

Best regards,
Helena Grulichova

User avatar
Member
Member
eliza.sahoo-gmail - 6/22/2010 6:36:49 AM
   
RE:Web Part Property Access
SharePoint allows you to create custom web parts to help you provide highly customized solutions to your clients/users. The properties of these web parts are added by default but to further customize the solution, you can also create custom properties. The following example demonstrates how to add a custom dropdown property to a custom webpart.
// Create a Enum for Languages

public enum LanguageByEnum
{
English = 0,
French,
Spanish
};

sharepoint migration india