R
ryan.d.rembaum
I am trying to make a very simple control that adds a "required"
property to a table cell. Setting the property to true automatically
should add a red asterick '*' to the end of any text it contains if the
value was previously false and is set to true. Conversly, if the value
is set to false and was true, the asterick should be removed.
To test I created a but that sets the value to the opposite of whatever
it is currently. The problem is that, though I am changing the value,
the value never gets stored.I thought it might be becuase of view
state, so I tried implementing IPOSTBACKDATAHANDLER, but unless I did
something wrong it did not seem to make a difference.
Does anyone know why the value is not being retained? Thanks!
My code is as follows:
Public Class RequirementCell : Inherits TableCell
Private _Required As Boolean
Public Property Required() As Boolean
Get
Return _Required
End Get
Set(ByVal Value As Boolean)
Dim strStart As Integer
If ((Value = True) And (_Required = False)) Then
Me.Text = Me.Text & "<B><font
color=""red"">*</B></FONT>"
ElseIf ((Value = False) And (_Required = True))
Then
strStart = InStr(Me.Text, "<B><font
color=""red"">*</B></FONT>")
If strStart > 0 Then
Me.Text = Mid(Me.Text, 1, strStart - 1)
End If
End If
_Required = Value
End Set
End Property
End Class
property to a table cell. Setting the property to true automatically
should add a red asterick '*' to the end of any text it contains if the
value was previously false and is set to true. Conversly, if the value
is set to false and was true, the asterick should be removed.
To test I created a but that sets the value to the opposite of whatever
it is currently. The problem is that, though I am changing the value,
the value never gets stored.I thought it might be becuase of view
state, so I tried implementing IPOSTBACKDATAHANDLER, but unless I did
something wrong it did not seem to make a difference.
Does anyone know why the value is not being retained? Thanks!
My code is as follows:
Public Class RequirementCell : Inherits TableCell
Private _Required As Boolean
Public Property Required() As Boolean
Get
Return _Required
End Get
Set(ByVal Value As Boolean)
Dim strStart As Integer
If ((Value = True) And (_Required = False)) Then
Me.Text = Me.Text & "<B><font
color=""red"">*</B></FONT>"
ElseIf ((Value = False) And (_Required = True))
Then
strStart = InStr(Me.Text, "<B><font
color=""red"">*</B></FONT>")
If strStart > 0 Then
Me.Text = Mid(Me.Text, 1, strStart - 1)
End If
End If
_Required = Value
End Set
End Property
End Class