Catching a RequiredFiled Validator event in PageLoad or some other event?

L

Lars Netzel

Hi!

If I use a RequiredField Validator to make sure a TextBox is filled by a
user and the user DOESN'T it triggers and shows the errortext of that
control.

I want more to happen on the page when that happens and is there an Event or
something I can check that it has been triggered?

Regards
/Lars
 
G

Greg Burns

I would guess your would need to create a Custom_Validator and not specify
the control to validate (that way it will run even when your TextBox is
empty).

Inside your Custom_Validator check to see if the TextBox was empty and act
on it.

Greg
 
D

DujHoD

I believe you can use the IsValid property of the validator itself to
check this.

http://msdn.microsoft.com/library/e...WebControlsBaseValidatorClassIsValidTopic.asp

Note that validation happens AFTER the Page_Load event, so if you get
this property in the Page_Load event, it will always return True,
since the control has not yet been validated. If you must check
validity in the Page_Load event, you can manually call the
Page.Validate method (or just call the Validate method of the
validator you want to check on).

http://msdn.microsoft.com/library/en-us/dnaspp/html/aspplusvalid.asp
 
G

Greg Burns

BUT, if he has client-side validation turned on he may never get back to the
server to run anything.

Greg

DujHoD said:
I believe you can use the IsValid property of the validator itself to
check this.

http://msdn.microsoft.com/library/e...WebControlsBaseValidatorClassIsValidTopic.asp

Note that validation happens AFTER the Page_Load event, so if you get
this property in the Page_Load event, it will always return True,
since the control has not yet been validated. If you must check
validity in the Page_Load event, you can manually call the
Page.Validate method (or just call the Validate method of the
validator you want to check on).

http://msdn.microsoft.com/library/en-us/dnaspp/html/aspplusvalid.asp


"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
If I use a RequiredField Validator to make sure a TextBox is filled by a
user and the user DOESN'T it triggers and shows the errortext of that
control.

I want more to happen on the page when that happens and is there an Event or
something I can check that it has been triggered?
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top