Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: RangeValidator and CompareValidator Controls Do Not Recognize Currency and Double Data


View products that this article applies to.

Symptoms

When you validate the Currency data or the Double data in an ASP.NET application by using the RangeValidator control or the CompareValidator control, and the data has a decimal point at the beginning or at the end, you receive the error message as mentioned in the ErrorMessage property of the Validator control.

↑ Back to the top


Cause

This problem occurs because RangeValidator and CompareValidator do not recognize input data of type Currency if the data has a decimal point at the beginning or at the end (for example, 25. or .25). Also, when input data has a decimal point at the end (for example, 25.), RangeValidator and CompareValidator do not recognize it as valid input data of type Double.

↑ Back to the top


Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


More information

Steps to Reproduce the Behavior

  1. In Microsoft Visual Studio .NET, create a new ASP.NET Web Application project by using Visual Basic .NET or Visual C# .NET. By default, WebForm1.aspx is created.
  2. Right-click WebForm1.aspx, and then click View HTML. Replace the existing code with the following sample code to add a TextBox control, a RangeValidator control, and a CompareValidator control:
    <%@ Page %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    	<HEAD>
    		<title>WebForm2</title>
    	</HEAD>
    	<body MS_POSITIONING="GridLayout">
    		<form id="WebForm2" method="post" runat="server">
    			<asp:TextBox id="TextBox1" runat="server"></asp:TextBox><br>
    			<asp:RangeValidator id="RangeValidator1" runat="server" ErrorMessage="Double-RangeValidator" ControlToValidate="TextBox1" Type="Double" MaximumValue="233" MinimumValue="0"></asp:RangeValidator>
    			&nbsp;&nbsp;
    			<asp:CompareValidator id="CompareValidator1" runat="server" ErrorMessage="Double-CompareValidator" ControlToValidate="TextBox1" Operator="GreaterThan" Type="Double" ValueToCompare="0"></asp:CompareValidator><br>
    			<asp:RangeValidator id="RangeValidator2" runat="server" ErrorMessage="Currency-RangeValidator" ControlToValidate="TextBox1" Type="Currency" MaximumValue="244" MinimumValue="0"></asp:RangeValidator>
    			&nbsp;&nbsp;
    			<asp:CompareValidator id="CompareValidator2" runat="server" ErrorMessage="Curency-CompareValidator" ControlToValidate="TextBox1" Operator="GreaterThanEqual" Type="Currency" ValueToCompare="0"></asp:CompareValidator><br>
    			<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
    		</form>
    	</body>
    </HTML>
    
  3. On the Debug menu, click Start to run the application.
  4. Type 25. in the text box, and then click Button. Verify that the validation error messages occurred for data types Double and Currency.
  5. Type .24 in the text box, and then click Button. Verify that the validation error messages occurred for the Currency data type.

↑ Back to the top


References

For more information about individual validation controls that are available in ASP.NET, visit the following Microsoft Web sites: For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
306459� INFO: ASP.NET Server Controls Overview

↑ Back to the top


Keywords: KB815187, kbbug, kbwebforms, kbservercontrols, kbvalidation, kbpending

↑ Back to the top

Article Info
Article ID : 815187
Revision : 8
Created on : 4/30/2003
Published on : 4/30/2003
Exists online : False
Views : 371