RadNumericTextBox Value Changing

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

    Posted 11 May 2017 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">
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
                <telerik:RadNumericTextBox runat="server" ID="txtDigits" Type="Number" MaxLength="20" MaxValue="99999999999999999999" Width="150px">
                    <NumberFormat DecimalDigits="0" AllowRounding="false" GroupSeparator="" NegativePattern="n" />




  2. Marin Bratanov
    Marin Bratanov avatar
    4494 posts

    Posted 15 May 2017 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;

    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)
    <telerik:RadNumericTextBox runat="server" ID="txtDigits" Type="Number" MaxLength="20" MaxValue="9007199254740992" Width="150px" AllowOutOfRangeAutoCorrect="false">
        <NumberFormat DecimalDigits="0" AllowRounding="false" GroupSeparator="" NegativePattern="n" />
    <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.


    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