More in this section

Forums / Developing with Sitefinity / How to add an button to Select page for customized control

How to add an button to Select page for customized control

6 posts, 0 answered
  1. Charles
    Charles avatar
    14 posts
    Registered:
    25 May 2007
    09 Aug 2007
    Link to this post
    Hi,

    In the new module, we can click the Select button to assign the SingleNewPage while edit the NewsList Control.

    How to add an button to Select page for my customized control?

    Thanks
  2. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    10 Aug 2007
    Link to this post
    Hi Charles,

    To have a "Select" button for a property in your custom control in the Control Properties view, you should specify a WebEditor attribute for this property, e.g. :

            /// <summary>  
            /// Gets or sets the page containing SingleNews control.  
            /// </summary>  
            [WebEditor("Telerik.Cms.Web.UI.UrlEditorWrapper, Telerik.Cms"),  
            Category("Behavior")]  
            public virtual string SingleNewsPage  
            {  
                get 
                {  
                    object obj = this.ViewState["SingleNewsPage"];  
                    if (obj != null)  
                        return (string)obj;  
                    return String.Empty;  
                }  
                set 
                {  
                    this.ViewState["SingleNewsPage"] = value;  
                }  
            } 


    The WebEditor attribute declares the type of control which will be loaded in the pop-up dialog on "Select" button clicked. You shoud create your own property editor or use an existing one. The property editor should impelement IWebUITypeEditor interface or WebUITypeEditor<T> abstract class. Here is the implementation of the base class for Type Editors, WebUITypeEditor<T>:

    using System;  
    using System.Web;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using System.Collections.Generic;  
    using System.Drawing.Design;  
    using System.Text;  
     
    namespace Telerik.Cms.Web.UI  
    {  
        public interface IWebUITypeEditor  
        {  
            UITypeEditorEditStyle GetEditStyle();  
            void EditValue(object value);  
            object Value { getset; }  
            string Title { get; }  
            object TypeContainer { getset; }  
            Control HostControl { getset; }  
            bool AutoSelect { getset; }  
            event EventHandler<ValueChangedEventArgs> ValueChanged;  
        }  
     
        public abstract class WebUITypeEditor<T> : CompositeControl, IWebUITypeEditor  
        {  
            public virtual UITypeEditorEditStyle GetEditStyle()  
            {  
                return UITypeEditorEditStyle.None;  
            }  
     
            public abstract T Value  
            {  
                get;  
                set;  
            }  
     
            object IWebUITypeEditor.Value  
            {  
                get 
                {  
                    return this.Value;  
                }  
                set 
                {  
                    this.Value = (T)value;  
                }  
            }  
     
            public virtual string Title  
            {  
                get 
                {  
                    return string.Empty;  
                }  
            }  
     
            public virtual object TypeContainer  
            {  
                get 
                {  
                    return this.typeContainer;  
                }  
                set 
                {  
                    this.typeContainer = value;  
                }  
            }  
     
            public virtual Control HostControl  
            {  
                get 
                {  
                    return this.hostControl;  
                }  
                set 
                {  
                    this.hostControl = value;  
                }  
            }  
     
            public virtual bool AutoSelect  
            {  
                get 
                {  
                    return false;  
                }  
                set 
                {  
                }  
            }  
     
            public virtual void EditValue(T value)  
            {  
            }  
     
            void IWebUITypeEditor.EditValue(object value)  
            {  
                this.EditValue((T)value);  
            }  
     
            protected virtual void OnValueChanged(ValueChangedEventArgs e)  
            {  
                if (this.ValueChanged != null)  
                    this.ValueChanged(this, e);  
            }  
     
            public event EventHandler<ValueChangedEventArgs> ValueChanged;  
     
            private object typeContainer;  
            private Control hostControl;  
        }  
    }  
     

    Hope this is helpful.


    All the best,

    Vlad
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center
  3. Charles
    Charles avatar
    14 posts
    Registered:
    25 May 2007
    10 Aug 2007
    Link to this post
    Thanks, it works now.

    Another question:

    How to add a downdown list with options from database while edit the customized control?

    Thanks
  4. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    13 Aug 2007
    Link to this post
    Hi Charles,

    Unfortunately, you should wait for the next release to accomplish this task, because currently in the control properties view a dropdown list appears only for properties of Enum and bool type.

    We are now working on control designers feature for version 3.1, which you could use to fit your needs. This feature will provide a mechanism for creating control designers for editing the control properties. The designer control will be an alternative way for editing the control. It will appear on the left side of the Properties tab (like in GenericContent). The idea is to have a user friendly interface for editing the most popular properties of the control.

    Please let us know if you have additional questions.

    Regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Charles
    Charles avatar
    14 posts
    Registered:
    25 May 2007
    11 Sep 2007
    Link to this post
    Hi,

    How to display a group of checkbox on the control property editor?

    Any release plan for 3.1?

    Thanks
  6. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    12 Sep 2007
    Link to this post
    Hello Charles,

    Currently, there is no type for which the CheckboxList is displayed in-line in the Properties View.
    You could use a property Web Editor to display it in a dialog.
    Or, in Sitefinity 3.1, you could create your custom Control Editor View (Control Designer), described in the previous post.
    The version 3.1 is scheduled for the end of September.

    Please let us know if we are missing something or you need additional information.

    Regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
6 posts, 0 answered