ASPX templates
Version 5.x > ASPX templates > Displaying a Document w/Transformation in an inline control View modes: 
User avatar
Member
Member
Ian Muir - 4/28/2011 3:39:05 PM
   
Displaying a Document w/Transformation in an inline control
I need to create a inline control that displays an instance of a document type using a predetermined transformation.

The control accepts a path to the document as the parameter. I can successfully retrieve the treeNode using the api, but I want to render it to the page using a transformation.

I was going to place a CmsViewer control into the user control and set the path using the code-behind, however the CmsViewer doesn't work with regular transformations, only XSLT.

Is there a way to apply a transformation to a node and get the rendered HTML using the API?

User avatar
Member
Member
kentico_michal - 4/29/2011 11:02:31 AM
   
RE:Displaying a Document w/Transformation in an inline control
Hello,

You can place a standard CMSRepeater control to the ascx code and set the class names, transformation name and other attributes to appropriate values. Then, in the code behind you set the Path property dynamically according to the current Parameter value and then call ReloadData method for the repeater so the property values would be updated.

Please take a look at following example:



<cms:CMSRepeater runat="server" ID="rep" ClassNames="CMS.News" TransformationName="CMS.News.Default" ></cms:CMSRepeater>



CODE BEHIND:
protected void Page_Load(object sender, EventArgs e)
{
rep.Path = this.Parameter;
rep.ReloadData(true);
}


Best regards,
Michal Legen

User avatar
Member
Member
Ian Muir - 4/29/2011 11:17:08 AM
   
RE:Displaying a Document w/Transformation in an inline control
Thanks Michal, I forgot the ReloadData call.