CustomValidator is not fired!
Posted on 2006-11-06
Hi, CustomValidator control is not fired when I submit the form, here is the code:
<asp:CustomValidator ControlToValidate="Departments" OnServerValidate="HasDepartment" Text="Employee should be assigned to a department" runat="server" ID="Departmentsvld" />
Public Sub HasDepartment(ByVal source As Object, ByVal args As ServerValidateEventArgs)
Dim blnHasDepartment As Boolean
blnHasDepartment = False
Dim LiThisOne As ListItem
For Each LiThisOne In Departments.Items
If LiThisOne.Selected Then
blnHasDepartment = True
If blnHasDepartment = True Then
args.IsValid = True
args.IsValid = False
Do someone know what I am doing wrong?