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

Forums / Developing with Sitefinity / Drop down list in custom control properties

Drop down list in custom control properties

7 posts, 0 answered
  1. LouiseBA
    LouiseBA avatar
    61 posts
    Registered:
    23 Mar 2010
    29 Apr 2010
    Link to this post
    Hi, I have seen a few posts around this topic, and have already read this

    http://sitefinitywatch.com/blog/09-03-10/Using_Enumerators_to_Auto-generate_a_Dropdown.aspx

    but this isnt what I want. Gabes example is a simple list of colours.  I need a drop down list that is furnished from the database, so enums are not appropriate (i dont think anyway) because I need a drop down list with a string text and a guid value, and to expose the guid value that the user chooses, for me to do some database logic in what to show in the view, which is my custom control. I am aware you have more flexibility with control designers and web editors for customising the properties section, but I really dont have time to delve into this right now, it looks quite involved. I just need a simple drop down box showing a list of things.

    Any ideas? Can I use enums in this way?

    Thanks, Louise.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    29 Apr 2010
    Link to this post
    Hello LouiseBA,

    You need to use Control Designers or WebUI TypeEditor. The properties section of the Designer wokrs only with enum, TextBox ( it is automatically generated) and boolean type properties ( true false DropDown is automatically generated).

    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.
  3. Frank Nieto
    Frank Nieto avatar
    5 posts
    Registered:
    30 May 2010
    30 May 2010
    Link to this post
    I looked at the code and I'm glad to say that it worked generally well in practice/tests.  However, being that the properties in the designer only supports enums, how can you make a drop down list to pull from dynamic content.

    The long story short is that I created a new Gallery module and when I embed the control in one of the pages, I need to be able to select from one of the many galleries that were defined in the module.  Enum wouldn't work because the end-user may add or remove from the available galleries and those changes need to be reflected in the drop down list.

    What do you suggest?

    Thanks,

    Frank
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    31 May 2010
    Link to this post
    Hi Frank Nieto,

    However, being that the properties in the designer only supports enums, how can you make a drop down list to pull from dynamic content.

    You can do this in the ControlDesigner and its template. You could expose a property in the control designer and the control. The selected value of the DropDown in the Control Designer will be set as a property of the control.

    sample code

    ControlDesigner

    protected override void CreateChildControls()
       {
           base.CreateChildControls();
     
           if (combo != null)
           {
            // here you can populate the RadComboBox - bind it to your data Source
      
           }
            // when you open the designer set the value of the Index property to the
            // RadComboBox control in the Designer
           combo.SelectedValue = ((CustomImageControl)DesignedControl).Index;
       }
     
     
     
     
       public override void OnSaving()
       {
     
           base.OnSaving();
         // set the Index property of your custom control to the Selected value of
         // the RadCombobox control
         ((CustomImageControl)DesignedControl).Index = combo.SelectedValue;  
       }
     
     
       public RadComboBox combo
       {
           get
           {
               return base.Container.GetControl<RadComboBox>("RadComboBox1", true);
           }
       }

    property in the CustomImageControl

    public string Index
        {
            get
            {
                object obj = this.ViewState["Index"];
                if (obj != null)
                    return (string)obj;
                return "";
     
            }
            set
            {
                this.ViewState["Index"] = value;
            }
        }


    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.
  5. Frank Nieto
    Frank Nieto avatar
    5 posts
    Registered:
    30 May 2010
    31 May 2010
    Link to this post
    Ivan,

    Thank you so much for your prompt reply.  I took your advise an between the sample you provided, other posts in the forums and the telerik reference documentation I was able to get it working.

    Frank
  6. Ishtiyaq
    Ishtiyaq avatar
    11 posts
    Registered:
    17 Sep 2011
    09 Jan 2012
    Link to this post
    HI Any one,

    I am unable to get it working. Can you Please send me the whole code working. When I try to use the Other Blog Posts for adding DropDown Unable to to get it working. As I am missing the Telerik.Framework.dll. Please, Advise me ASAP.

    Regards,
    Ishtiyaq Mohammed
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    09 Jan 2012
    Link to this post
    Hello,

    Telerik.Framewrok.dll should be in your bin folder. You need to use Control Designers or WebUI TypeEditor.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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