Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > add web container to web part programmatically View modes: 
User avatar
Member
Member
maggie.nu-gmail - 6/9/2011 7:36:01 AM
   
add web container to web part programmatically
how to add webcontainer programmatically?

<cc1:CMSRepeater ID="CMSclients" runat="server" ClassNames="Gama.clients" TransformationName="Gama.clients.list" SelectedItemTransformationName="Gama.clients.default" >
</cc1:CMSRepeater>

User avatar
Member
Member
lancetek - 6/9/2011 8:26:19 AM
   
RE:add web container to web part programmatically
I've not done this but I assume that as Kentico is just an ASP.NET application, you can add objects to the page like you normally would. ie: the CMSRepeater is just an object that you can instantiate in the codebehind and add to the page.

See msdn for more info on how to do this in an ASP.NET application.

I wouldn't consider this an EASY thing to do, as you'll have to mess around with maybe creating your own controls and changing the codebehind files.

I'm not sure why you want to do this, but perhaps you may want to investigate the generic 'visibility' property that most web parts have, so that it only gets shown in certain circumstances?

Or maybe you're trying to do a nested repeater approach?

Good luck,
Lance

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 6/9/2011 10:56:36 PM
   
RE:add web container to web part programmatically
Hello,

Could you please describe us your aim in more details? (The more the better :-) )

Well, since you are sticking this post to the Portal engine forum, I guess that you are referring to the Web Part Container, right? If this is the case, please note the web part containers are meant to server for the web parts only.

In your case, are you about to use that repeater in the transformation?

Best regards
Ondrej Vasil

User avatar
Member
Member
maggie.nu-gmail - 6/10/2011 1:20:35 AM
   
RE:add web container to web part programmatically
yes that exactly right , i want to use the repeater inside the transformation
i also have video webpart that has need to have a container

<cc2:Video VideoURL='<%#ResolveUrl("http://"+ Request.Url.Host + GetFileUrl("Video").ToString()) %>' runat="server" Id="video" Width="200" Height="100" ContainerTitle="Video"  Container=   />


i tried to write container = "blackbox" but i keep getting error
cannot convert string to type


User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 6/10/2011 8:18:43 AM
   
RE:add web container to web part programmatically
Hi,

the Container property needs as a paramater WebPartContainerInfo object, not string. Could you please try to use following code:


<uc1:repeater ID="rptNestedPage" runat="server" ClassNames="cms.menuitem" TransformationName="CMS.MenuItem.inner" />

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
//Black.Box is a code name of container (Site Manager - Development - Web part //containers)
rptNestedPage.Container = CMS.PortalEngine.WebPartContainerInfoProvider.GetWebPartContainerInfo("Black.Box");
}


If it does not work, you can set properties ContentBefore, ContentAfter to simulate the container.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
maggie.nu-gmail - 6/10/2011 12:40:53 PM
   
RE:add web container to web part programmatically
Thanks i will check it up :-)