A
A Traveler
Hello all,
I have a control i wrote which inherits from asp:label. It worked fine. It
extends asp:label with a "For" property which implements the "for" attribute
of an html label tag (yes i know the latest framework vers. added this, but
i want ot get mine right as a learning exp.).
I added a designer class which turns the For property into a dropdown list
of the names of all the controls so you can simply pick one. When i added
the designer, the control no longer properly initialized its Text property
when you drop it on a webform. I THINK the problem is in then designer's
Initialize sub.
The code for my designer is shown below.
When i drop the control on a page now, the text property starts out as ""
instead of with the controls id. If someone could tell me how to get this to
properly initialize.
Thanks in advance,
- Arthur Dent.
===== BEGIN CODE ================================
Public Class LabelDesigner
Inherits ControlDesigner
Private pLabel As Label
Public Overrides Sub Initialize(ByVal component As IComponent)
MyBase.Initialize(component)
pLabel = CType(component, Label)
'pLabel.Text = pLabel.ID
End Sub
Public Property [For]() As String
Get
Return pLabel.For
End Get
Set(ByVal Value As String)
pLabel.For = Value
End Set
End Property
Protected Overrides Sub PreFilterProperties(ByVal properties As
IDictionary)
MyBase.PostFilterProperties(properties)
Dim prop As PropertyDescriptor = CType(properties("For"),
PropertyDescriptor)
If Not prop Is Nothing Then
prop = TypeDescriptor.CreateProperty(Me.GetType(), prop, New
Attribute() {New TypeConverterAttribute(GetType(ForConvertor))})
properties("For") = prop
End If
End Sub
End Class
I have a control i wrote which inherits from asp:label. It worked fine. It
extends asp:label with a "For" property which implements the "for" attribute
of an html label tag (yes i know the latest framework vers. added this, but
i want ot get mine right as a learning exp.).
I added a designer class which turns the For property into a dropdown list
of the names of all the controls so you can simply pick one. When i added
the designer, the control no longer properly initialized its Text property
when you drop it on a webform. I THINK the problem is in then designer's
Initialize sub.
The code for my designer is shown below.
When i drop the control on a page now, the text property starts out as ""
instead of with the controls id. If someone could tell me how to get this to
properly initialize.
Thanks in advance,
- Arthur Dent.
===== BEGIN CODE ================================
Public Class LabelDesigner
Inherits ControlDesigner
Private pLabel As Label
Public Overrides Sub Initialize(ByVal component As IComponent)
MyBase.Initialize(component)
pLabel = CType(component, Label)
'pLabel.Text = pLabel.ID
End Sub
Public Property [For]() As String
Get
Return pLabel.For
End Get
Set(ByVal Value As String)
pLabel.For = Value
End Set
End Property
Protected Overrides Sub PreFilterProperties(ByVal properties As
IDictionary)
MyBase.PostFilterProperties(properties)
Dim prop As PropertyDescriptor = CType(properties("For"),
PropertyDescriptor)
If Not prop Is Nothing Then
prop = TypeDescriptor.CreateProperty(Me.GetType(), prop, New
Attribute() {New TypeConverterAttribute(GetType(ForConvertor))})
properties("For") = prop
End If
End Sub
End Class