Microsoft KB Archive/815187

From BetaArchive Wiki

Article ID: 815187

Article Last Modified on 4/30/2003



APPLIES TO

  • Microsoft ASP.NET 1.0
  • Microsoft ASP.NET 1.1




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.

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.

STATUS

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

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


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


Keywords: kbbug kbvalidation kbwebforms kbpending kbservercontrols KB815187