[thelist] Custom validation ASP.net

Ken Schaefer Ken at adOpenStatic.com
Mon Dec 10 20:41:43 CST 2007


In your code, you have an <asp:customvalidator /> control?

And you set the onservervalidate property to your custom function (e.g. onservervalidate="MyCustomValidator")?

Then, in your code section, you'd do something like:

Sub MyCustomValidator(ByVal s As Object, ByVal e As ServerValidateEventArgs)

        If txtEmail.Text.Length > 0 or txtPhone.Text.Length > 0 then
                e.isValid = True
                e.isValid = False
        End If

End Sub

And then in your Page_Load() sub you'd have something like:

If Page.IsValid() then

        ' Do good stuff

End If



-----Original Message-----
From: thelist-bounces at lists.evolt.org [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Michael Pack
Sent: Tuesday, 11 December 2007 2:58 AM
To: thelist at lists.evolt.org
Subject: [thelist] Custom validation ASP.net

Hi folks, have a easy question for you ASP.net guru's.

I'm building a web form and want to require the email OR phone number .
This is simple to me with Javascript, but how would I go about this
utilizing a custom .net validation control?

I've been trying to learn how to create a custom control but am having
trouble with it, using the following argument...

(!String.IsNullOrEmpty(txtEmail.Text) ||

Writing VB in Dreamweaver CS3 without code behind.

Thanks in advance!

More information about the thelist mailing list