3

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 Answers 4

2

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

Add this to your web-parts code-behind.

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

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.

1
  • We have created our master setup and portal manager/engine as per kentico documentation. Feb 21, 2017 at 18:08
0

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.

4
  • Nope, we've got a portal manager in there according to kentico documention. Feb 21, 2017 at 18:07
  • Did you check how it was done in Kentico ASPX templates in CMSTemplates/CorporateSite?
    – P Kozjak
    Feb 22, 2017 at 6:25
  • It's literally a copy/paste directly from the documentation as seen here: docs.kentico.com/k10/developing-websites/… Feb 22, 2017 at 17:10
  • Additionally, the editable regions are set up in an acx and placed multiple times on the page. The problem is that the editable region controls go into the database using the server id, not the client id. Hence, the last one on the page will overwrite the values of the editable regions in the other two ascx controls since they are all identified in the kentico database by the same ID. Feb 23, 2017 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.