How do I write a customValidator script?

  • Thread starter Thread starter darrel
  • Start date Start date
D

darrel

I have a dropdown list, 'DrpDwnContacts' that I want to validate and see if
the first item is select. If it is, It's not valid.

So, I've added a customValidator, 'DrpDwnContacts_CustomValidator' which
creates a sub, 'DrpDwnContacts_CustomValidator_ServerValidate'

The question is, what do I put in that function to get it to return a
isValid response?

This is what I have:

Private Sub DrpDwnContacts_CustomValidator_ServerValidate(ByVal source As
System.Object, ByVal args As
System.Web.UI.WebControls.ServerValidateEventArgs) Handles
DrpDwnContacts_CustomValidator.ServerValidate

if DrpDwnContacts.Items(0).Selected = True then
DrpDwnContacts_CustomValidator.IsValid = False
else
DrpDwnContacts_CustomValidator.IsValid = True
End If

End Sub

But that doesn't seem to be working.

-Darrel
 
if(ddl.SelectedIndex > 0)
{
...ok
}

Actually, it wasn't the if I was stuck on, but how to return the
valid/invalid property. I did figure it out though:

args.isvalid=true

-Darrel
 
Back
Top