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

Forums / Developing with Sitefinity / Extending Controls examples

Extending Controls examples

7 posts, 0 answered
  1. Bruno Michels
    Bruno Michels avatar
    125 posts
    Registered:
    16 Apr 2010
    28 Apr 2010
    Link to this post
    Hi,

    I want to know how to extend controls. How can I add new fields to PollBox Control?

    Where can I find examples of PollBox, Search... ?
  2. Bruno Michels
    Bruno Michels avatar
    125 posts
    Registered:
    16 Apr 2010
    28 Apr 2010
    Link to this post
    I tried to extend PollBox

    using System;
    using System.ComponentModel;
    using System.Web.UI;
     
    namespace Sitefinity.Poll
    {
        public class PollView : Telerik.Polls.WebControls.PollBox
        {
            #region Properties
            /// <summary>
            /// Gets or sets Publication date
            /// </summary>
            [Browsable(true)]
            [Category("Publication")]
            [DisplayName("Data de publicação")]
            [Description("Data de publicação da enquete")]
            public string DatePublication { get; set; }
            #endregion
        }
    }


    Result: Nothing changed, when I drag n' drop the control, it appears as a PollBox control and my property is not there...

    Isn't it right the way I'm trying to do?
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    28 Apr 2010
    Link to this post
    Hello Bruno Michels,

    You should create a ToolBox Item for your control as shown below

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Telerik.Polls.Resources;
     
    namespace Telerik.Samples.WebControls
    {
        using Telerik.Web;
     
        public class CustomPollBoxToolboxItem : ToolboxItem
        {
     
            public CustomPollBoxToolboxItem () : base(typeof(PollView))
            {
                this.DisplayName ="DisplayName";
                this.Description = "Description";
            }
        }
    }


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  4. Bruno Michels
    Bruno Michels avatar
    125 posts
    Registered:
    16 Apr 2010
    28 Apr 2010
    Link to this post
    using System;
    using System.ComponentModel;
    using System.Web.UI;
     
    namespace Sitefinity.Poll
    {
        public class PollView : Telerik.Polls.WebControls.PollBox
        {
            #region Properties
            /// <summary>
            /// Gets or sets Publication date
            /// </summary>
            [Browsable(true)]
            [Category("Publication")]
            [DisplayName("Data de publicação")]
            [Description("Data de publicação da enquete")]
            public string DatePublication { get; set; }
            #endregion
        }
    }

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Telerik.Polls.Resources;
      
    namespace Sitefinity.Poll
    {
        using Telerik.Web;
      
        public class PollViewToolboxItem : ToolboxItem
        {
      
            public PollViewToolboxItem() : base(typeof(PollView))
            {
                this.DisplayName ="Pool View";
                this.Description = "Controle de enquete";
            }
        }
    }

    <add name="Poll View" section="QUAY" type="Sitefinity.Poll.PollViewToolboxItem,Sitefinity.Poll" description="Controle de enquete do site" />

    Like this?

    Error:
    Can't cast 'Sitefinity.Poll.PollViewToolboxItem' to 'System.Web.UI.Control'.
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    28 Apr 2010
    Link to this post
    Hi Bruno Michels,

    You do not have to register the toolbox in the web.config as a separate control. You just need to associate your custom control with a single property to use the toolbox.

    [ToolboxItem(typeof(PollViewToolboxItem))]
    public class PollView : PollBox
    {
      //
    }


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Bruno Michels
    Bruno Michels avatar
    125 posts
    Registered:
    16 Apr 2010
    28 Apr 2010
    Link to this post
    Error
    Invalid resource name (Telerik.Polls.Resources.ControlTemplates.Frontend.PollBox.ascx) for assembly (Sitefinity.Poll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null) or empty template.

    using System;
    using System.ComponentModel;
    using System.Web.UI;
     
    namespace Sitefinity.Poll
    {
        [ToolboxItem(typeof(PollViewToolboxItem))]
        public class PollView : Telerik.Polls.WebControls.PollBox
        {
            #region Properties
            /// <summary>
            /// Gets or sets Publication date
            /// </summary>
            [Browsable(true)]
            [Category("Publication")]
            [DisplayName("Data de publicação")]
            [Description("Data de publicação da enquete")]
            public string DatePublication { get; set; }
            #endregion
        }
    }

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Telerik.Polls.Resources;
      
    namespace Sitefinity.Poll
    {
        using Telerik.Web;
      
        public class PollViewToolboxItem : ToolboxItem
        {
      
            public PollViewToolboxItem() : base(typeof(PollView))
            {
                this.DisplayName ="Pool View";
                this.Description = "Controle de enquete";
            }
        }
    }

    <add name="Poll View" section="QUAY" type="Sitefinity.Poll.PollView,Sitefinity.Poll" description="Controle de enquete do site" />
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    28 Apr 2010
    Link to this post
    Hi Bruno Michels,

    Override the template path properties of the control. Otherwise the control is looking for the embedded template which you cannot access.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
7 posts, 0 answered