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

Forums / Developing with Sitefinity / User Control wrapping Image Control

User Control wrapping Image Control

4 posts, 0 answered
  1. Ricardo Marcelino
    Ricardo Marcelino avatar
    15 posts
    Registered:
    04 Nov 2009
    13 Nov 2009
    Link to this post
    Hello!

    I've created a User Control that has a Generic Content Control. Thanks to your guides, i have it working, and i can edit it in Page Mode, like i was drag & dropping a Generic Content Control.

    Now, on the same User Control i've created, i want to add a Image Control, that i can edit in Page Mode, just like the editing options a user has when he drags & drops a single Image Control.

    Can Telerik help me with the code to this specific control?

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="imageGenCont.ascx.cs" Inherits="imageGenCont" %> 
    <%@ Register Assembly="Telerik.Cms.Engine" Namespace="Telerik.Cms.Engine.WebControls" TagPrefix="sfWeb" %> 
     
    <sfWeb:SitefinityImage id="sfImageId" runat="server" /> 
    <sfWeb:GenericContent id="genericContent_ImgTxt" runat="server" /> 
    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.ComponentModel; 
    using System.Collections; 
    using System.Configuration; 
    using System.Data; 
    using System.Web.Security; 
    using System.Web.UI.HtmlControls; 
    using System.Web.UI.WebControls.WebParts; 
    using Telerik.Cms; 
    using Telerik.Cms.Web.UI; 
    using Telerik.Web; 
    using Telerik.Cms.Engine; 
    using Telerik.Framework.Web.Design; 
    using Telerik.Cms.Engine.WebControls; 
    using Telerik.Framework.Configuration; 
    using Telerik.Utilities; 
     
    [ControlDesignerAttribute("Telerik.Cms.Engine.WebControls.Design.GenericContentDesigner, Telerik.Cms.Engine")] 
     
    //guessing i have to start with this? 
    [ControlDesignerAttribute("Telerik.Cms.Engine.WebControls.Design.SitefinityImage, Telerik.Cms.Engine")] 
     
    public partial class imageGenCont : System.Web.UI.UserControl, IGenericContent 
        protected void Page_Load(object sender, EventArgs e) 
        { 
     
        } 
     
        #region IGenericContent Members 
        [CmsBrowsable(false)] 
        [CmsPersistable(true)] 
         
        public string Content 
        { 
            get 
            { 
                return genericContent_ImgTxt.Content; 
            } 
            set 
            { 
                genericContent_ImgTxt.Content = value;             
            } 
        } 
        [Browsable(false)] 
        public Guid ContentID 
        { 
            get 
            { 
                return genericContent_ImgTxt.ContentID; 
            } 
            set 
            { 
                genericContent_ImgTxt.ContentID = value
            } 
        } 
        public string ProviderName 
        { 
            get 
            { 
                return genericContent_ImgTxt.ProviderName; 
            } 
            set 
            { 
                genericContent_ImgTxt.ProviderName = value
            } 
        } 
        [Browsable(false)] 
        public IContent SharedContent 
        { 
            get 
            { 
                return this.genericContent_ImgTxt.SharedContent; 
            } 
        } 
        public bool UseStagedVersion 
        { 
            get 
            { 
                return genericContent_ImgTxt.UseStagedVersion; 
            } 
            set 
            { 
                genericContent_ImgTxt.UseStagedVersion = value
            } 
        } 
        [CmsBrowsable(false), CmsPersistable(true)] 
        public bool HasDynamicLinks 
        { 
            get 
            { 
                return genericContent_ImgTxt.HasDynamicLinks; 
            } 
            set 
            { 
                genericContent_ImgTxt.HasDynamicLinks = value
            } 
        } 
        public string GetItemUrl(string provider, Guid id, bool resolveAsAbsoluteUrl) 
        { 
            return genericContent_ImgTxt.GetItemUrl(provider, id, resolveAsAbsoluteUrl); 
        } 
        public void RenderBinaryContent(HtmlTextWriter writer) 
        { 
            genericContent_ImgTxt.RenderBinaryContent(writer); 
        } 
        public void RenderTextContent(HtmlTextWriter writer) 
        { 
            genericContent_ImgTxt.RenderTextContent(writer); 
        } 
        #endregion  
     }   
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Nov 2009
    Link to this post
    Hi Ricardo Marcelino,

    You should create a public property of type SitefinityImage from where you can edit the control properties.

    public SitefinityImage SfImage
    {
        get
        {
            return this.sfImageId;
        }
        set
        {
            this.sfImageId = value;
        }
    }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Ricardo Marcelino
    Ricardo Marcelino avatar
    15 posts
    Registered:
    04 Nov 2009
    13 Nov 2009
    Link to this post
    Hello Ivan,

    But for me to be able do edit the control's properties in Sitefinity, when i'm editing a Page, i have to get the design of the Image Control, right?

    That is what i'm aiming for, because the purpose, in the end, should be draggin' one User control, and two other appear (Image control and Generic Content control), with them being editable when editing a Page, just like i dragged one of each one, at a time.

    Thanks for the quick reply.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Nov 2009
    Link to this post
    Hello Ricardo Marcelino,

    First, you have declared both controls in one control which means that you need to expose the properties as I showed you. Controls that work in the same way are PollBox, EventsScheduleView, RadPanelBar. You can open them and you will see that PollBox wraps ResultsBox, EventsScheduleView wraps RadScheduler, SitePanelBar wraps RadPanelBar. If you want to have the UI for both the controls you need to create a custom designer for your control. In the basic tab of the custom designer you can have two slides( as it is doe for NewsView) - one for GenericContent and another for SitefinityImage. When you call OnSaving method you will need to persists the properties of both the controls. You can gather more information about control designers at

    Introduction to Sitefinity Control Designers
    Making Control Editing User-Friendly with Sitefinity Control Designers
    Creating Highly Usable Distributable Sitefinity Controls

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
4 posts, 0 answered