By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,656 Members | 801 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,656 IT Pros & Developers. It's quick & easy.

Range validation and international date formats

P: n/a
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?

--
Brendan Reynolds
Oct 4 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

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?

--
Brendan Reynolds

"Brendan Reynolds" <br******@discussions.microsoft.comwrote in message
news:uB**************@TK2MSFTNGP06.phx.gbl...
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?

--
Brendan Reynolds

Oct 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.