Custom Controls Creation (property)

Discussion in 'ASP .Net' started by Alex Nitulescu, Feb 22, 2005.

  1. Hi. I'm creating my first custom controls. I have this code:

    Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)

    output.AddAttribute("color", [Color])
    output.RenderBeginTag("font")
    output.RenderBeginTag("b")
    output.Write(Reverse([Text]))
    output.RenderEndTag()
    output.RenderEndTag()
    End Sub

    <Description("Color of the text"), Bindable(True), Category("Appearance"),
    DefaultValue("Black")> Property [Color]() As String

    Get
    Return _color
    End Get

    Set(ByVal Value As String)
    _color = Value
    End Set
    End Property

    where color is defined as string, as you can see. Therefore, in the
    Properties of my UserControl, of course, "Color" expects a string. How can I
    make my "color" property, in this example, to show the same as ForeColor,
    for instance (with the color-picker already there). I know how to create
    enumerations, I need the color-picker !

    Also, please, is there a way to teach the IDE to list the properties of my
    custom control, the same way it opens the listbox with the properties
    (width, text, etc) and methods of, say, a built-in textbox ??? Currently, if
    I add a property name, for instance "MyOriginalProperty" to a control, the
    user who writes html would need to know that there is such a property,
    "MyOriginalProperty"...

    Thank you very much !
    Alex
     
    Alex Nitulescu, Feb 22, 2005
    #1
    1. Advertisements

  2. Alex Nitulescu

    Guest Guest

    Hi Alex
    Public Property color() As String
    Get
    Return textbox1.Style("ForColor")
    End Get
    Set(ByVal Value As String)
    textbox1.Style("forcolor") = Value
    End Set
    End Property
    '''''''''''''''''''''''''
    hope this help
    '''''''''''''''''''''''''''''
     
    Guest, Feb 22, 2005
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.