How do I write a customValidator script?

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
 
D

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top