Results 1 to 3 of 3

Thread: [2005] User control property to have a drop down list of values

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    [2005] User control property to have a drop down list of values

    I am developing a web user control and have a property exposed of type object. What I want is that when this user control is placed on a web form this property will pick up all the textboxes and give the user an option to choose from those values. Something very similar to what we've in CompareValidator where we get to choose the name of the control to compare etc. Any ideas where I should start from? Thanks.

  2. #2
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: [2005] User control property to have a drop down list of values

    Create an Enum with the properties
    vb Code:
    1. Public Enum PropertiesEnum
    2. Item1
    3. Item2
    4. Item3
    5. End Enum
    6.  
    7. Public Property PropertyTest() As PropertiesEnum
    8. Get
    9. Dim intValue As Integer = Cint(ViewState("PropertyTest"))
    10.  
    11. Return intValue
    12. End Get
    13. Set (byval value As PropertiesEnum)
    14. ViewState("PropertyTest") = value
    15.  
    16. End Set
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: [2005] User control property to have a drop down list of values

    Thanks Warren for the reply but that's not what exactly I'm trying to achieve. Let me try to explain it again.
    a.) On a web form I'll place my user control.
    b.) User control has a property, TextBoxToFill.
    c.) Developer will go into the property and then he should see a list of all the textboxes that are available on the current web form (where the user control has been placed).

    What I've tried so far:
    In a CustomCompareValidator I've put the attribute
    Code:
    TypeConverter(GetType(ControlIDConverter))
    before a property and that property is able to pick up all the available controls on the form where it has been placed. But when I put the same attribute in this user control it doesn't work. ANy idea why would it be so?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width