ASPX templates
Version 6.x > ASPX templates > CMSEditableRegion not storing content in dynamic loaded usercontrol View modes: 
User avatar
Certified Developer 9
Certified Developer 9
jali-scor - 3/26/2012 10:48:10 AM
   
CMSEditableRegion not storing content in dynamic loaded usercontrol
I have a situation where I need to dynamically load an usercontrol (event: Page_Load). This usercontrol contains a CMSEditableRegion. The content isn't stored in the CMS.

Is it possible to save content of a CMSEditableRegion in combination with dynamically loaded usercontrols? If not, is there another option for me to use a CMSEditableRegion in the usercontrol?

Thanks!


User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/27/2012 2:22:22 AM
   
RE:CMSEditableRegion not storing content in dynamic loaded usercontrol
Hi,

dynamic loaded control is only loaded. I mean it loads the content from configured editable region. If you save the content on child it will break inheritance, because be default is selected editable content from the current document.

Example:

1. Parent A - has TESTParent in its editable region
2. Child B - has dynamically loaded content from parent's editable region and contains TESTParent as well
3. Now you save the content on Child B with content TestChild. Since now the editable content of child document will contain TestChild, not TESTParent.

Here is the example code which supports above behavior

Parent template:

<asp:Content ID="Content1" ContentPlaceHolderID="plcMain" runat="Server">
<cms:CMSEditableRegion ID="txtRight" runat="server" DialogHeight="400" RegionType="HtmlEditor" RegionTitle="Right" />

</asp:Content>


Child template markup:

<asp:Content ID="Content1" ContentPlaceHolderID="plcMain" runat="Server">
<cms:CMSEditableRegion ID="txtRight" runat="server" DialogHeight="400" RegionType="HtmlEditor" RegionTitle="Right" Enabled="false" /> <%--Content inherited from section landing page--%>

</asp:Content>


Child template code behind:

protected void Page_Load(object sender, EventArgs e)
{
if (CMSContext.CurrentDocumentParent != null)
{
var pageInfo = CMS.PortalEngine.PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, CMSContext.CurrentDocumentParent.NodeAliasPath, "en-US", null, true);

txtRight.LoadContent(pageInfo);
}
}


Best regards,
Ivana Tomanickova