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

Forums / Developing with Sitefinity / Control Properties

Control Properties

11 posts, 0 answered
  1. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    22 Oct 2008
    Link to this post
    Is there a way (easily) to create a property for my control that will give the user a drop down selection of choices that i define in the SiteFinity admin?

    Additionally if the property is a bool value, is there a way to make SiteFinity display this as a CheckBox?

    Duncan
  2. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    22 Oct 2008
    Link to this post
    Also is there a way to require a property for the control be set by the CMS user?
  3. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    22 Oct 2008
    Link to this post
    The dropdown with manageable list of options will take some work.

    However, the bool property is terribly easy.  Just add the following code to your UserControl:

    1     public bool ExistingCustomer  
    2     {  
    3         get 
    4         {  
    5             return _existingcustomer;  
    6         }  
    7         set 
    8         {  
    9             _existingcustomer = value;  
    10         }  
    11     }  
    12  
    13     private bool _existingcustomer = false;  
    14  
    15  
    16  


    Now when you click "Edit" for your control in the Sitefinity page editor, you'll see this new property. 

    Let me ponder your other question and I will reply a bit later...

    Gabe Sumner

  4. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    22 Oct 2008
    Link to this post
    Hi Gabe,

    Thanks for the reply... I actually have a number of properties going right now but noticed that for a bool value it displays a drop down for true or false... It's no big deal was just wondering if there was a way to display it as a checkbox...

    Duncan
  5. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    22 Oct 2008
    Link to this post
    How about a date entry, is there a WebEditor control that will have the user select a date?

    Also where can i find a FULL list of these WebEditor's i can use?

    Duncan
  6. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    22 Oct 2008
    Link to this post
    Hi Duncan,

    Sorry I didn't read your first post more carefully.  I don't know a quick way to convert the True/False dropdown to a checkbox.  I know a Control Designer would work, but this is a lot of work and might be overkill:

    http://www.sitefinity.com/help/developer-manual/adding-user-controls-implementing-control-designers.html

    Regarding a full list of WebEditors (TypeEditors), all TypeEditors need to inherit from WebUITypeEditor.  I searched for "Inherit WebUITypeEditor" in the Sitefinity documentations.  Here are my results:

    http://search.telerik.com/search?q=%22Inherits+WebUITypeEditor%22&entqr=0&customFilter=PID463_RID7&output=xml_no_dtd&sort=date%3AD%3AL%3Ad1&btnG.y=12&client=help&filter=p&num=20&btnG.x=56&ud=1&site=helpsitefinity&oe=UTF-8&ie=UTF-8&proxystylesheet=help

    You should be able to use these Type Editors on your public properties.  Example:

        [Telerik.Cms.Web.UI.WebEditor("Telerik.Rss.WebControls.RssFeedSelector")]  
        public string RSSURL  
        {  
            get 
            {  
                return _rssurl;  
            }  
            set 
            {  
                _rssurl = value;  
            }  
        }  
     
        private string _rssurl;  
     
     


    Gabe Sumner


  7. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    22 Oct 2008
    Link to this post
    One last question Gabe, and then i promise to leave you alone... (for today, lol)

    Is there a way to (either in the code behind of the control or in the permissions of the page/control) to disable the other property groups. I do not want anyone (other than admins) to be able to modify the control properties such as the ID fo the control or any property under the Behavior category of the control properties...

    I was playing with the permissions, but there is not way to be specific like i want to be. No way to set permissions on certain properties of the control, it's either they get to view and modify the properties or not...

    That said my question really is about disabling them all together from showing up in SiteFinity (i can modify them via visual studios if i need)

    Duncan
  8. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    22 Oct 2008
    Link to this post
    The following code will hide this property from the Sitefinity control editor:

        [System.ComponentModel.Browsable(false)]  
        public bool SuperSecret  
        {  
            get 
            {  
                return _supersecret;  
            }  
            set 
            {  
                _supersecret = value;  
            }  
     
        }  
     
        private bool _supersecret = false;  
     
     

    You're just tagging your property with a "Browsable" attribute.  I believe this will do what you want.  Let me know if not though.

    Gabe Sumner


  9. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    22 Oct 2008
    Link to this post
    Can i do this for the already existing properties (not my custom ones) like ID, EnableViewState, EnableTheming and Visible?

    Duncan
  10. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    22 Oct 2008
    Link to this post
    Try this:


        [System.ComponentModel.Browsable(false)] 
        public override bool EnableTheming 
        { 
            get 
            { 
                return base.EnableTheming; 
            } 
            set 
            { 
                base.EnableTheming = value; 
            } 
        } 
     
     
     


    Override each underlying property you want hide and add the "Browable" attribute.

    Gabe Sumner


  11. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    22 Oct 2008
    Link to this post
    That worked. Thank you sir!

    Duncan
Register for webinar
11 posts, 0 answered