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

Forums / Developing with Sitefinity / Edit properties of a User Control

Edit properties of a User Control

6 posts, 0 answered
  1. Nick
    Nick avatar
    91 posts
    Registered:
    04 Aug 2008
    05 Sep 2008
    Link to this post
    Hi!

    I have made a custom user control which has one editable property.

    I originally implemented this property, in the C# code behind file, as a String. However this means that when it came to editing the property, a text field was the method of entry, where as a drop down would be the ideal solution.

    Since sitefinity automatically picks up on any properties, i thought that maybe implementing the property as an enumeration, that sitefinity would auto-generate a drop down list for each potential value of the enumeration. However i have found this is not the case (unless i have done something wrong).

    Is there any way in which this property could be represented as a drop down list in the public side of property editing?

    Thanks,
    Nick
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    05 Sep 2008
    Link to this post
    I've only ever seen a drop down menu as a 'built in' property editor for a user control when the property is a boolean. I get a drop down with a true/false choice... if you want to change the editor interface for a control, take a look at this article from the developer manual:

    Implementing Control Designers on User Control
    http://www.sitefinity.com/help/developer-manual/adding-user-controls-implementing-control-designers.html

    it has an overview and a sample project you can use to create a control designer that for editing the properties of your control.

    hope this was helpful!
  3. Vlad
    Vlad avatar
    498 posts
    Registered:
    15 Jul 2016
    08 Sep 2008
    Link to this post
    Hi,

    Actually, adding a control property of enum type should auto-generate a drop down list for editing it in the Property Editor. So your thoughts about this are correct.
    Could you please send us your User Control, so we could see what is the problem in your case?


    All the best,
    Vlad
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  4. Nick
    Nick avatar
    91 posts
    Registered:
    04 Aug 2008
    08 Sep 2008
    Link to this post
    my mistake, i've got it working now with an ENUM. i think it's because i set, out of habit, the property in question to be private!

    thanks for confirming my suspicion that an enum would do the job :-)
  5. Bachar Zeidan
    Bachar Zeidan avatar
    67 posts
    Registered:
    01 Jul 2010
    27 Aug 2010
    Link to this post

    hello every body


    I'am trying to get a dropdownlist control in  my back end custom Control.  I think that with enum type i will be able to resolve the problem.

    here is my code


     

     

    Public Enum Locations

     

     

    Office = 1

    Region = 2

     

    End Enum

     

     

     

     

     

     

    Private _location As Locations = Locations.Office


     

    <ComponentModel.Bindable(

    False), Category("Customize"), DefaultValue(""), _

     

    Description(

    "test")> _

     

     

    Public Property Location() As Locations

     

     

     

    Get

     

     

     

     

     

    Return _location

     

     

    End Get

     

     

     

     

     

    Set(ByVal value As Locations)

     

    _location = value

     

    End Set

     

     

     

     

     

    End Property





    could you write an example please...how to get a dropdownlist control!!

    thx you very much

     

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    27 Aug 2010
    Link to this post
    Hi Bachar Zeidan,

    Here is  a sample code

    public enum Colors
    {
        red,
        green,
        blue
    }
    public Colors Mode
    {
        get
        {
            return this._colors;
        }
        set
        {
            this._colors = value;
        }
    }
     
    private Colors _colors;


    Sincerely yours,
    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
6 posts, 0 answered