API Questions on Kentico API.
Version 6.x > API > Dynamically Create CMSPagePlaceHolder Template View modes: 
User avatar
Member
Member
eric.rovtar - 10/25/2011 9:25:33 PM
   
Dynamically Create CMSPagePlaceHolder Template
I am trying to create a CMSPagePlaceHolder in code-behind. This is what I have so far:
CMSPagePlaceholder pph = new CMSPagePlaceholder();

CMSWebPartZone wpz = new CMSWebPartZone();
wpz.ID = String.Format("testZone");

pph.WebPartZones.Add(wpz);

phZones.Controls.Add(pph);


When I try to assign to pph.LayoutTemplate it says it takes an object of type ITemplate. I'm just wondering how I go about creating the ITemplate object.

If you could please provide an object, that'd be great!

Thanks,
Eric

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 11/2/2011 2:33:28 AM
   
RE:Dynamically Create CMSPagePlaceHolder Template
Hi,

how to create an ITemplate object and create template dynamically is described in this msdn article:
http://msdn.microsoft.com/en-us/library/0e39s2ck.aspx

The page place holder can be created this way and your code seems to be correct:

CMSPagePlaceholder pph = new CMSPagePlaceholder();
myPlaceHolder.Controls.Add(pph);

Markup:

<asp:PlaceHolder runat="server" ID="myPlaceHolder" />

Best regards,
Ivana Tomanickova