+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Custom Control with Sitefinity Image and Other custom controls

Custom Control with Sitefinity Image and Other custom controls

3 posts, 0 answered
  1. Paritosh Arya
    Paritosh Arya avatar
    10 posts
    Registered:
    18 Dec 2009
    26 Aug 2010
    Link to this post
    I have this requirement to develop a custom control that is nothing but a collection of some sitefinity controls and some custom developed controls (see the attachment for the layout).

    I have developed some custom controls for "Headline","BodyText" and "Bulleted List". Now I need to create the main control which has sitefinity image control and the controls that I created. I am totally lost on how to go about it.

    Could you please help me out in how to develop something like that? I looked at something similar for hint http://www.sitefinity.com/help/developer-manual/how-to-gc-add-content-to-user-control.html but that is far more simpler than my requirement.

    I need to expose all the properties present on my custom controls and that of sitefinity image control.

    Any help and sample on this would be highly appreciable.

    Thanks in advance! 

  2. Paritosh Arya
    Paritosh Arya avatar
    10 posts
    Registered:
    18 Dec 2009
    26 Aug 2010
    Link to this post
    I think i figured this out. For people who might need help in implementing something like this, here's what i did

    1) Created a user control with sitefinity controls and my custom controls-

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ImageDataControl.ascx.cs" Inherits="UserControls_ImageDataControl" %>
    <%@ Register Assembly="Telerik.Cms.Engine" Namespace="Telerik.Cms.Engine.WebControls" TagPrefix="sfWeb" %>
    <%@ Register Assembly="SubServicingControls" Namespace="SubServicingControls" TagPrefix="ss" %>
    <table>
        <tr>
            <td rowspan="3">
                <sfWeb:SitefinityImage ID="siImage" runat="server"/>
            </td>
            <td>
                <ss:Headline id="headLine" runat="server"/>
            </td>
        </tr>
        <tr>
            <td>
                <ss:BulletedList id="bulletedList" runat="server"/>
            </td>
        </tr>
    </table>

    2) In the code behind, i exposed properties which directly set the values of the controls and their underlying properties -
    [WebEditor("Telerik.Libraries.WebControls.ImageSelector, Telerik.Cms.Engine")]
        [TypeConverter(typeof(StringConverter))]
        [Category("Image")]
        public string ImageUrl
        {
            get
            {
                return siImage.ImageUrl;
            }
      
            set
            {
                siImage.ImageUrl = VirtualPathUtility.ToAbsolute(value);
            }
        }
      
      
    [Category("Headline")]
        public string Header
        {
            get
            {
                return headLine.Header;
            }
      
            set
            {
                headLine.Header = value;
            }
        }
    [Category("Bulleted List")]
        [WebEditor("SubServicingControls.SaxonBulletedListEditor, SubServicingControls"), Browsable(true)]
        [TypeConverter("SubServicingControls.ListConverter, SubServicingControls")]
        public List<string> ListItems
        {
            get
            {
                if (bulletedList.ListItems == null)
                    bulletedList.ListItems = new List<string>();
                return bulletedList.ListItems;
            }
            set
            {
                bulletedList.ListItems = value;
            }
        }

  3. Eric Marthinsen
    Eric Marthinsen avatar
    12 posts
    Registered:
    20 Jun 2005
    10 Oct 2010
    Link to this post
    Thanks for posting this. Very helpful.

    Regards,
    Eric
Register for webinar
3 posts, 0 answered