3
votes

I have three CMSEditableRegion controls inside of an ascx which needs to be on an aspx page 3 or more times.

The problem is that each of the region controls will always contain the content of the last set of them.

After doing a little research, I've found out it saves the content of the control in the database under the ID of the control meaning that the first CMSEditableRegion will have its content overwritten by the last CMSEditableRegion's content (since there are at least three with the same server ID - one per ascx). Well, rather, that was for Kentico 5 but what I'm seeing tends to support this. Unfortunately, the solution I found for Kentico 5 does not work in Kentico 10.

How can I have multiple CMSEditableRegion controls in an ascx that is going to be on the aspx page multiple times?

Edit: We are indeed using the portal manager (correctly) and our master is set up using the specified Kentico Documentation.

4

4 Answers

2
votes

You need to ensure each CMSEditableRegion's control ID is unique so that the data for each instance is stored separately in the database.

You can achieve this by setting the ID of the control in the codebehind file of your web part ascx.

Place the CMSEditableRegion into your ascx...

<cms:CMSEditableRegion runat="server" ID="cerContent" RegionTitle="WYSIWYG" RegionType="HtmlEditor" />

...and then set the control's ID in the code behind...

cerContent.ID = this.ID + cerContent.ID;

The unique ID is generated here by concatinating the control's ID with this.ID, which is the unique ID of the web part's instance when it is placed on a page.

Works for me in Kentico 10.

1
votes

Add this to your web-parts code-behind.

public override void OnContentLoaded()
{
    base.OnContentLoaded();
    if (!this.StopProcessing)
    {
        theCMSEditableRegion.ID = theCMSEditableRegion.ID + base.ID;
    }
}
0
votes

When you use portal engine you can have as many as you want and that should apply to aspx development model. Did you follow the example? I would look inside the DB to make sure that XML is saved correctly:

select CONVERT(xml,DocumentContent), * from cms_document where documentid = 123

When you save web parts (in portal engine this is the equivalent of CMSEditableRegion), the xml looks like this:

<content>
  <webpart id="editabletext1;fe77e447-3af4-440f-a736-7c1e321cb3fc">456</webpart>
  <webpart id="editabletext;3bb22493-8e7d-47c1-9dc0-dfc5aeff3157">123</webpart>
</content>

Yours should look the same or very similar. it might have something to do the IDs or bindings.

0
votes

I think you are missing Portal Manager:

<cms:CMSPortalManager ID="manPortal" runat="server" EnableViewState="false" />

But easiest way to understand how this works is to open Kentico APX template in CMSTemplates/CorporateSite. In there you will find master page (root.master) with Home page template (HomeASPX.aspx). In master you can see portal manager is placed and in home you can add as many editable regions as you want. I did try this.

Hope this solves your problem.