Range validation and international date formats

  • Thread starter Brendan Reynolds
  • Start date
B

Brendan Reynolds

In an ASP.NET 1.1 app I have the following range validation control. This is
an intranet app that will be used only within Ireland, so all date input is
expected to be in dd/mm/yyyy format.

<asp:RangeValidator id="varngRollCallDate" runat="server"
ErrorMessage="Please enter a valid date in 'dd/mm/yyyy' format."
ControlToValidate="txtDate" Display="Dynamic" Type="Date"
MinimumValue="01/01/2006" MaximumValue="31/12/2006"
EnableClientScript="True"></asp:RangeValidator>

On my development PC (Windows XP Pro SP2, locale = English (Ireland), short
date format = dd/mm/yyyyy) this works as expected, accepting dates in
dd/mm/yyyy format between 1st January 2006 and 31st December 2006. But on a
server running Windows Server 2003, same locale and date format, loading the
page throws a System.Web.HttpException complaining that the value
'31/12/2006' can not be converted to type Date. If I change the Maximum
Value property to '12/31/2006' the exception is no longer thrown, so it
appears that on the server the validation control is expecting US
'mm/dd/yyyy' date format.

What do I need to do to have the validation control use dd/mm/yyyy format on
the server?
 
B

Brendan Reynolds

Adding the following page directive fixed it ...

culture="en-IE"

I'm still a little puzzled though, as to why adding the page directive
worked, while adding the culture attribute to the globalization section of
web.config didn't?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top