Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

requiredFieldValidater and checking for null values

1 view
Skip to first unread message

Andy B

unread,
Apr 25, 2008, 12:28:31 PM4/25/08
to
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?

Nathan Sokalski

unread,
Apr 25, 2008, 12:50:02 PM4/25/08
to
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.
--
Nathan Sokalski
njsok...@hotmail.com
http://www.nathansokalski.com/

"Andy B" <a_b...@sbcglobal.net> wrote in message
news:ON2SeFvp...@TK2MSFTNGP05.phx.gbl...

Stan

unread,
Apr 26, 2008, 5:45:51 AM4/26/08
to
On 25 Apr, 17:28, "Andy B" <a_bo...@sbcglobal.net> wrote:
> 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.

0 new messages