RadNumericTextBox Value Changing

2 posts, 0 answers
  1. Rob
    Rob avatar
    116 posts
    Member since:
    Aug 2012

    Posted 11 May Link to this post

    Hi Telerik,

    I have a very simple example with a RadNumericTextBox control set to allow a maximum or 20 numeric characters with a MaxValue of 99999999999999999999.  The issue is after entering 16 or more digits and then make the control lose focus causes the value to change.  For example, 88888888888888888888 changes to 88888888888888880000.  99999999999999999999 changes to 10000000000000000000.  Please help me make sense of what's going on.  In my opinion, the value shouldn't change.

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="RadTextBoxTest.aspx.vb" Inherits="Pages_RadTextBoxTest" %>
     
    <!DOCTYPE html>
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
            <div>
                <telerik:RadNumericTextBox runat="server" ID="txtDigits" Type="Number" MaxLength="20" MaxValue="99999999999999999999" Width="150px">
                    <NumberFormat DecimalDigits="0" AllowRounding="false" GroupSeparator="" NegativePattern="n" />
                </telerik:RadNumericTextBox>
            </div>
        </form>
    </body>
    </html>

     

    Thanks,

    Rob

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3916 posts

    Posted 15 May Link to this post

    Hello Rob,

    The Value property of the numeric textbox is of type nullable double. The largest number you can fit in it is 9007199254740992 and 88888888888888888888 is more than that. If you try to put that in a simple double? variable you will get an exception:

    protected void Page_Load(object sender, EventArgs e)
    {
        double? test = 88888888888888888888;
        Response.Write(test);
    }

    It is also important to note that the double format representation uses exponents, try inputting 1234567891234570 in the following code and you will get 1.23456789123457E+15 even with the AllowOutOfRangeAutoCorrect property set to false.

    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write(txtDigits.Value);
    }
    <telerik:RadNumericTextBox runat="server" ID="txtDigits" Type="Number" MaxLength="20" MaxValue="9007199254740992" Width="150px" AllowOutOfRangeAutoCorrect="false">
        <NumberFormat DecimalDigits="0" AllowRounding="false" GroupSeparator="" NegativePattern="n" />
    </telerik:RadNumericTextBox>
    <asp:Button ID="Button1" Text="test" OnClick="Button1_Click" runat="server" />

    Ultimately, if you need to use such large values you may want to consider a string input with a regex that only allows digits in it.

    Regards,

    Marin Bratanov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top