ASP.NET Framework 1.1 Validation not working in IE7?

I recently had a problem with an old Framework 1.1 website where the form would not post back if the page contained validators (CustomValidators to be exact). It caused me to do a lot of googling and in the end some javascript debugging.

It was a strange problem, the site worked fine in IE6 and Firefox; just IE7 failed. Searching the web I was suppried that nobody else was complaining about this.. surely it was a 1.1 IE7 bug??

First clue

onsubmit="if (!ValidatorOnSubmit()) return false;"

In the onSubmit attribute of the form tag there is a call to ValidatorOnSubmit(). When Alerting this in JavaScript it returned "Undefined"

I checked that the scriptmaps were ok and even reinstalled them using ASPNET_REGIIS -s <path>. Still no dice.

The solution

It turned out that .net Framework 1.1 SP1 had been installed on the server but this site had local copies of the pre SP1 WebUIValidation.js file.

I replaced the files with the correct ones and things started to work... sort of..

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\ASP.NETClientFiles

Problems with pre SP1 code and the CustomValidator control

The validation now triggered. Slight problem, it always failed, without even doing the postback it needed to perform server-side validation.

The solution was to add a dummy custom validator function to allow client validation to pass client-side checks before doing server-side validation.

<script>
     function customvalidatorDummy(source,args){
        args.IsValid=true;
     }
</script>

<ASP:CUSTOMVALIDATOR ClientValidationFunction="customvalidatorDummy" ... />
Author Paul Hayman

Paul is the COO of kwiboo ltd and has more than 20 years IT consultancy experience. He has consulted for a number of blue chip companies and has been exposed to the folowing sectors: Utilities, Telecommunications, Insurance, Media, Investment Banking, Leisure, Legal, CRM, Pharmaceuticals, Interactive Gaming, Mobile Communications, Online Services.

Paul is the COO and co-founder of kwiboo (http://www.kwiboo.com/) and is also the creator of GeekZilla.

Add Comment

Name
Comment
 

Your comment has been received and will be shown once it passes moderation.