CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Peter's Gekko

public Blog MyNotepad : Imho { }

Scripting errors on an aspx page, validatorcontrols and causesvalidation ('undefined' is null or not an object)

The ASP.NET toolbox has some nice validator controls like RequiredFieldValidator and RangeValidator. These perform a first validation of client input in the browser. On postback the validation is repeated on the server. The client side validation is not supported in every browser and is skipped in some scenarios. A side effect of the validation scripts is that a page with validator controls sometimes pops up quite mysterious scripting errors. This is because validation is, by default, performed on every roundtrip. In some scenarios this can lead to invisible controls being validated with null values and script errors like 'undefined' is null or not an object.

The good thing is that you can disable validation on a control base. Every control which can force a postback, like a button or linkbutton, has the CausesValidation property. Default it is set to true. Set it to false in case there is nothing to validate and your script errors are gone.


Published Sep 09 2005, 08:11 AM by pvanooijen
Filed under:

Comments

Rob said:

useless info
# June 26, 2006 1:10 PM

pvanooijen said:

That's a contradiction in terms :)
What were you looking for ?
# June 27, 2006 3:03 AM

Travich said:

I agree, very useless -- I hate sites like this that post keywords on a topic you're looking on just so they'll get hits.  It's equivalent to those trapping middle of the aisle mall sales guys trying to sale you lotion.  I hate it.  I hate it I tell you.

# October 24, 2007 11:53 AM

pvanooijen said:

In case you were googling on something as wide as 'undefined' is null or not an object there is indeed only a .0005% chance this will be the cause of your problem. Which is still a greater chance than earnin something googling for 'Become rich without work'

In case you are working with asp.net validator controls this info does have its value.

# October 25, 2007 3:43 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!

This Blog

Syndication

News