Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Adding a webpart to a webpart programatically View modes: 
User avatar
Member
Member
richard.boyd-swgfl.org - 2/12/2009 10:57:57 AM
   
Adding a webpart to a webpart programatically
I'm developing a webpart in which I would like to implement the SocialBookmarking webpart, but I'm struggling to understand how I go about creating an instance of the SocialBookmarking webpart within my custom webpart programatically.

Is there a way to import the SocialBookmarking.ascx file into my webpart and create an instance of it using code?

Any help much appreciated.

Regards,
Richard.

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 2/13/2009 4:27:20 AM
   
RE:Adding a webpart to a webpart programatically
Hello,

Please go through the chapter in our Developer's Guide regarding webpart development:

http://devnet.kentico.com/docs/devguide/developing_web_parts.htm

Best regards
Ondrej Vasil

User avatar
Member
Member
richard.boyd-swgfl.org - 2/13/2009 7:50:00 AM
   
RE:Adding a webpart to a webpart programatically
Thanks; however, I've already referred to the developer's guide and it doesn't seem to go into this level of detail. It explains how to add a CMS control to the web part, but I want to programatically include a webpart which does not have an associaed CMS control (the SocialBookmarking webpart) - is this possible?

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 2/18/2009 7:06:22 AM
   
RE:Adding a webpart to a webpart programatically
Hello,

you could add a control which has the source URL of appropriate web part source code.

For example (adding a Random Products web part into control):

<%@ Register Src="~/CMSWebParts/Ecommerce/RandomProducts.ascx" TagName="RandomProducts" TagPrefix="uc1" %>

and then you use it like this:

<uc1:RandomProducts runat="server" ID="RandomProducts" OnlyNRandomProducts="1" Path="/Products/%" TransformationName="ecommerce.transformations.Product_Featured" Visible="true" />

I hope it is now clearer for you.

Best regards,
Helena Grulichova

User avatar
Member
Member
boyd-darena - 2/22/2009 2:24:29 PM
   
RE:Adding a webpart to a webpart programatically
Thanks Helena, this works perfectly.