Site structure
Version 7.x > Site structure > Composite web part of web parts id/content issues View modes: 
User avatar
Member
Member
pnmcosta - 11/21/2013 1:19:51 PM
   
Composite web part of web parts id/content issues
Hi,

Have got a composite web part of another web part repeated 4 times (not in repeater), FourImageAndTextBlocks:

<div class="grid-parent">
<div class="box grid-25 mobile-grid-25">
<div class="bgwhite clearfix grid-parent">
<uc1:ImageAndTextBlock runat="server" ID="ImageAndTextBlock" />
</div>
</div>
<div class="box grid-25 mobile-grid-25">
<div class="bgwhite clearfix grid-parent">
<uc1:ImageAndTextBlock runat="server" ID="ImageAndTextBlock1" />
</div>
</div>
<div class="box grid-25 mobile-grid-25">
<div class="bgwhite clearfix grid-parent">
<uc1:ImageAndTextBlock runat="server" ID="ImageAndTextBlock2" />
</div>
</div>
<div class="box grid-25 mobile-grid-25">
<div class="bgwhite clearfix grid-parent">
<uc1:ImageAndTextBlock runat="server" ID="ImageAndTextBlock3" />
</div>
</div>
</div>

And here is ImageAndTextBlock:

<cms:CMSEditableImage ID="imageContent" runat="server" ImageTitle="Image" />
<asp:Panel ID="panelTextWrap" runat="server">
<cms:CMSEditableRegion runat="server" ID="textContent" RegionType="HtmlEditor" RegionTitle="Text Content" />
</asp:Panel>

I'm well aware of the id naming issues so:

public partial class <snip>_FourImageAndTextBlocks : CMSAbstractWebPart
{
protected void Page_Init(object sender, EventArgs e)
{
this.ImageAndTextBlock.ID = "ImageAndTextBlock_" + this.ID;
this.ImageAndTextBlock1.ID = "ImageAndTextBlock1_" + this.ID;
this.ImageAndTextBlock2.ID = "ImageAndTextBlock2_" + this.ID;
this.ImageAndTextBlock3.ID = "ImageAndTextBlock3_" + this.ID;
}

And:

public partial class <snip>_ImageAndTextBlock : CMSAbstractWebPart
{
protected void Page_Init(object sender, EventArgs e)
{
this.imageContent.ID = "imageContent_" + this.ID;
this.panelTextWrap.ID = "panelTextWrap_" + this.ID;
this.textContent.ID = "textContent_" + this.ID;
}

Have also tried doing it overriding:

public override void OnContentLoaded()
{
// set child ids here
base.OnContentLoaded();
SetupControl();
}

With no avail, and get better results on Page_Init.

However on Portal Engine, when I have the FourImageAndTextBlocks web part repeated twice in a document, the same contents appear for both, e.g. each ImageAndTextBlock is same per FourImageAndTextBlocks

Can anyone shed any light on this?

I'm getting familiar with Kentico's API and inwards, but can't understand why this is happening cause I've checked on the HTML and the IDs are unique.

Many thanks for your help in advance.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 11/28/2013 2:40:25 AM
   
RE:Composite web part of web parts id/content issues
Hello,

I would suggest to modify the code and instead of "this.ID" use "WebPartID".

I hope it will help.

Best regards,
Juraj Ondrus