requiredFieldValidater and checking for null values

A

Andy B

Is it a good idea to check for null/invalid values even though you have the
requiredFieldValidater doing it for you? or is that a little overboard?
 
N

Nathan Sokalski

Yes, it is a good idea, because it can be easy to forget to check the
IsValid property, and if a hacker for some reason decided to adjust your
code for the validator you would end up with an error. Validators are
intended to make the user interface more friendly for users while filling
out a form, they are not intended to be used as insurance that all values
are valid. However, keep in mind that many form controls (such as TextBox)
will never be null. It may have a Text property of zero length, but it's
still a String. A CheckBox is always True or False, one of the ListItems in
a DropDownList is always selected, etc. Hopefully this helps.
 
S

Stan

Is it a good idea to check for null/invalid values even though you have the
requiredFieldValidater doing it for you? or is that a little overboard?

A RequiredFieldValidator only checks for an empty textbox or undefined
values. It does not check for valid content when it exists.

Other types of validator control can check for coherent content but in
a security critical application you may prefer to carry out further
verification using server-side code. Probably wise.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top