How to get and set a web part property value in a transformation

   —   
This article describes how to get and set a web part property value in a transformation.
To get and set a web part property value in a transformation, you need to modify your transformation by adding code similar to that of the example below. This example code works with the Title attribute property. It basically goes in a loop and searches for particular webpart. When it finds it, it gets the appropriate webpart property.


<%@ Register TagPrefix="cc2" Namespace="CMS.PortalControls" Assembly="CMS.PortalControls" %>

<script runat="server">

public CMSAbstractWebPart FindWebpart(Control o)
{

if (o is CMSAbstractWebPart)
{
return o as CMSAbstractWebPart;

}
else
{
if (o.Parent != null)
{

return FindWebpart(o.Parent);
}
else
{
return null;
}
}
}

public string GetWebPartTitle()
{
CMSAbstractWebPart currentWebpart = FindWebpart(this);

if (currentWebpart != null)
{

return ValidationHelper.GetString(currentWebpart.GetValue("WebPartTitle"), "");
}
else
{

return null;
}
}
</script>


<%=GetWebPartTitle() %>



-it-


See also: Writing transformations
Web parts

Applies to: Kentico CMS 5.5
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.