How to fix the Asp.net CalendarExtender and CompareValidator to accept European date formats

by Steve French in ASP.net, How To Fix on October 1, 2010

The Problem: You want to use the standard European Date Format, DD/MM/YYYY instead of the American Date Format MM/DD/YYYY.  You change the “Format” feature of the CalendarExtender to “DD/MM/YYYY”, but then the CompareValidator (which you’re using to ensure valid dates) calls out that you have entered an invalid date.

The Cause: The Compare Validator is expecting a different date format than it receives, and throws the error.   You will then notice that there is no “Format” attribute on the CompareValidator.

The Solution: Add the following line to the System.Web portion of your web.config file.

<globalization culture=”fr-FR”/>

That’s it!

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog