E
Earl Teigrob
I am trying to add a property to my CheckBoxList control that renders the
output as text if my own 'ViewOnly' property is set. This works for my
inherited of TextBox and RadioButtonList but I am losing the viewstate
selected items after the first time I render the text only. Is there a way to
save the view state inforation in the control or do I need to write my own
code to maintain view starte. Below is an example of my code. The ViewOnly
property is my own viewstate properties. Thanks for your help.
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
If ViewOnly Then
Dim Delimiter As String
If Me.RepeatDirection = WebControls.RepeatDirection.Horizontal
Then
Delimiter = ", "
Else
Delimiter = "<br>"
End If
Dim FirstPass As Boolean = True
For Each Item As ListItem In Me.Items
If Item.Selected Then
If Not FirstPass Then
writer.Write(Delimiter)
End If
writer.Write(Item.Text)
FirstPass = False
End If
Next
Else
MyBase.Render(writer)
End If
End Sub
output as text if my own 'ViewOnly' property is set. This works for my
inherited of TextBox and RadioButtonList but I am losing the viewstate
selected items after the first time I render the text only. Is there a way to
save the view state inforation in the control or do I need to write my own
code to maintain view starte. Below is an example of my code. The ViewOnly
property is my own viewstate properties. Thanks for your help.
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
If ViewOnly Then
Dim Delimiter As String
If Me.RepeatDirection = WebControls.RepeatDirection.Horizontal
Then
Delimiter = ", "
Else
Delimiter = "<br>"
End If
Dim FirstPass As Boolean = True
For Each Item As ListItem In Me.Items
If Item.Selected Then
If Not FirstPass Then
writer.Write(Delimiter)
End If
writer.Write(Item.Text)
FirstPass = False
End If
Next
Else
MyBase.Render(writer)
End If
End Sub