|
ListValidator sample |
Public Class ListValidator Inherits BaseValidator Protected Overrides Function ControlPropertiesValid() As Boolean Dim ctrl As Control = TryCast(FindControl(ControlToValidate), ListControl) Return (Not ctrl Is Nothing) End Function Protected Overrides Function EvaluateIsValid() As Boolean Return Me.CheckIfItemIsChecked() End Function Protected Function CheckIfItemIsChecked() As Boolean Dim listItemValidate As ListControl = (CType(Me.FindControl(Me.ControlToValidate), ListControl)) For Each listItem As ListItem In listItemValidate.Items If listItem.Selected = True Then Return True End If Next listItem Return False End Function End Class |