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.