views:

226

answers:

3

I know this may be a noob question, but it's bugging the heck out of me.

Let's say I have a user control that I reference in my .aspx page:

<uc:somecontrol runat="server" id="uc1" property1="red" />

how do I make it so when in VS05 the intellisense will show options like "red", "green", "blue" for property1? Similar to how when you want to choose between "text", "multiline", and "password" for the modes on a textbox. I'm using VB.

Thanks!

+13  A: 

Make your property an enum instead of a string.

Enum ControlColor
Red = 1
Blue = 2
Green = 3
End Enum

and

Public Property MyProperty As ControlColor
Rex M
A: 

Thanks, Rex! How do I do that, exactly?

Jason
This should not be added here. Add responses to answers as a comment please.
Chris Ballance
See the code sample and accept the answer if it works for you :). And in the future, be sure to follow workflow as @Chris Ballance recommended
Rex M
sorry... i'm kind of new here... will in the future. what's the rest of the property? what am i getting and setting? just some private integer as usual?
Jason
@dotnetdiscussion.net you can set a private member of the same type (in my example, a ControlColor)
Rex M
THANK YOU SO MUCH!!
Jason
+4  A: 

Define an enum in a new file as Rex said:

Public Enum ControlColor
    Red = 1
    Blue = 2
    Green = 3
End Enum

And then in your control, define your property like this (my VB syntax is rusty, but I think this is right):

Private _color As ControlColor

Public Property [Color] As ControlColor
    Get
        Return _color
    End Get
    Set (ByVal value As ControlColor)
        _color = value
    End Set
End Property
Max Schmeling
thank you max, rex beat you to it though!
Jason