Microsoft KB Archive/937096

= Error message when you try to open an ASP.NET-based Web page: &quot;MaximumValue property of 'RangeValidator1' cannot be converted to type 'Date'&quot; =

Article ID: 937096

Article Last Modified on 5/17/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.1

-



SYMPTOMS
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.



CAUSE
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.



WORKAROUND
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 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. 



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

<div class="moreinformation_section">

MORE INFORMATION
To reproduce this problem, open the ASP.NET-based Web page that contains the following code. <%@ Page language=&quot;c#&quot; AutoEventWireup=&quot;True&quot; %> <HTML> <HEAD> <script runat=&quot;server&quot;>

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(&quot;hu-HU&quot;);

RangeValidator1.Type = ValidationDataType.Date; RangeValidator1.MaximumValue = DateTime.Now.ToShortDateString; RangeValidator1.MinimumValue = DateTime.Now.ToShortDateString; }

</HEAD> <form id=&quot;Form1&quot; method=&quot;post&quot; runat=&quot;server&quot;> <asp:TextBox id=&quot;TextBox1&quot; runat=&quot;server&quot;></asp:TextBox> <asp:RangeValidator id=&quot;RangeValidator1&quot; runat=&quot;server&quot; ErrorMessage=&quot;RangeValidator&quot; ControlToValidate=&quot;TextBox1&quot;></asp:RangeValidator> </HTML>

Keywords: kbtshoot kbprb KB937096

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.