This is a migrated thread and some comments may be shown as answers.

RadNumericTextBox Value Changing

3 Answers 1110 Views
Input
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 11 May 2017, 06:22 PM

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

3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 15 May 2017, 02:10 PM

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.
0
Vasssek
Top achievements
Rank 1
answered on 11 Sep 2019, 02:14 PM

Hi,

this property AllowOutOfRangeAutoCorrect property should be set to false by default. Otherwise, when somebody type 123456789012345 radtextbox shows 70368744177664, which is not very understable why.

Thank you

 

0
Attila Antal
Telerik team
answered on 16 Sep 2019, 08:28 AM

Hi Vasssek,

 

RadNumericTextBox by default is set to handle the maximum value of "70368744177664" and since the value you are trying to introduce is greater than that, the control will automatically replace the number with the maximum allowed value.

You can adjust the default maximum value of the RadNumericTextBox by defining a bigger number in its MaxValue property:

For example:

Allow number up to "123456789012345"

<telerik:RadNumericTextBox ID="RadNumericTextBox2" NumberFormat-DecimalDigits="0" MaxValue="123456789012345" runat="server">
</telerik:RadNumericTextBox>

 

You can also set the MaxValue property in the code behind. Here are couple of examples using the Integer types' MaxValue:

protected void Page_Load(object sender, EventArgs e)
{
    // Int16.MavValue = 32767
    RadNumericTextBox1.MaxValue = Int16.MaxValue;
    // Int32.MavValue = 2147483647
    RadNumericTextBox2.MaxValue = Int32.MaxValue;
    // Int64.MavValue = 9223372036854775807
    RadNumericTextBox3.MaxValue = Int64.MaxValue;
}

 

Please note that the RadNumericTextBox is currently under investigation. It appears that the maximum Value it can handle is "545445456456465000" even if the MaxValue is set to higher (e.g. Int64). This issue is reported at: RadNumericTextBox changes its value regardless of the MaxValue property

 

Kind regards,
Attila Antal
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Input
Asked by
Rob
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Vasssek
Top achievements
Rank 1
Attila Antal
Telerik team
Share this question
or