Author: Crisp_Ice | Posted on: 6/30/2010 6:21:48 AM | Views : 315

I have a custom validator to check that a listbox contains at least 1 item but it isn't working. When I click my submit button the error message isn't showing when the listbox contains no items.
Here is my listbox:
<td valign="top"> <asp:ListBox ID="fileListBox" runat="server" Width="155px" /> <asp:CustomValidator ID="filesInList" runat="server" ControlToValidate="fileListBox" OnServerValidate="fileCountCheck" Display="Dynamic" ErrorMessage="Files must be selected!" /> </td>
Here is the validator:
Sub fileCountCheck(ByVal source As Object, ByVal args As ServerValidateEventArgs) If fileListBox.Items.Count > 0 Then args.IsValid = True Else args.IsValid = ...

Go to the complete details ...