Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 937096 - Last Review: May 17, 2007 - Revision: 1.2
Error message when you try to open an ASP.NET-based Web page: "MaximumValue property of 'RangeValidator1' cannot be converted to type 'Date'"
When you try to open a Microsoft ASP.NET-based Web page, you may receive an error message that resembles the following:
The value '2004. 04. 12.' of the MaximumValue property of 'RangeValidator1' cannot be converted to type 'Date'.
This problem may occur if the following conditions are true:
- You set the browser language to Hungarian [hu].
- You type a valid Hungarian format date in a field. Hungarian dates may use the following format:
12. 4. 2004
Notice that a space appears after the period (.) character.
Note This problem also occurs for Slovak date formats and for Bulgarian date formats.
This problem occurs when you use the
RangeValidator ASP.NET server control to provide client-side validation for the ASP.NET Web page. For example, this problem occurs if you set the
EnableClientScript property to True.
To work around this problem, use one of the following methods:
- Install the hotfix that is described in Microsoft Knowledge Base article 834330.
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
834330Â
(http://kbalertz.com/Feedback.aspx?kbNumber=834330/
)
FIX: The CompareValidator ASP.NET server control does not recognize valid Slovak dates in the .NET Framework 1.1
- Use the CustomValidator control together with the following regular expressions.
(^\\s*((\\d{4})|(\\d{2}))([-/]|\\. ?)(\\d{1,2})\\5(\\d{1,2})\\s*$)|(^\\s*((\\d{4})|(\\d{2}))\\.(\\d{1,2})\\.(\\d{1,2})\\s*\\.$)
(^\\s*(\\d{1,2})([-/]|\\. ?)(\\d{1,2})\\3((\\d{4})|(\\d{2}))\\s*$)|(^\\s*(\\d{1,2})\\.(\\d{1,2})\\.((\\d{4})|(\\d{2}))\\s*$)
Note The CustomValidator control checks the user's entry by using validation logic that you code. This kind of validation lets you check for values that are derived at run time.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
To reproduce this problem, open the ASP.NET-based Web page that contains the following code.
<%@ Page language="c#" AutoEventWireup="True" %>
<HTML>
<HEAD>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
//Use Hungarian date format, for example 2006. 07. 13.
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("hu-HU");
RangeValidator1.Type = ValidationDataType.Date;
RangeValidator1.MaximumValue = DateTime.Now.ToShortDateString();
RangeValidator1.MinimumValue = DateTime.Now.ToShortDateString();
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:RangeValidator id="RangeValidator1" runat="server" ErrorMessage="RangeValidator" ControlToValidate="TextBox1"></asp:RangeValidator>
</form>
</body>
</HTML>
APPLIES TO
- Microsoft .NET Framework 1.1
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate