RadNumericTextbox incorrect decimal places

4 posts, 1 answers
  1. Antony
    Antony avatar
    57 posts
    Member since:
    Oct 2008

    Posted 21 Apr 2009 Link to this post

    Hi everyone,

    I have a RadNumericTextbox on a page that is set to display 2 decimal places.
    If I set the initial value in the Page_Load to be 16.67 and then increase this value using the up arrow the control behaves as expected.
    If I decrement this value below the initial 16.67 then the number suddenly displays 15,670000000000001 (15 decimal places), if I increment the number back to 16.67 or greater the decimal places displayed returns to 2.
    I have tracked this down to the "AllowRounding" property, if set to false this behaviour occurs, if set to True the control behaves as expected.
    Why is this happening? I need to set AllowRounding = false and do not want these additional decimal places.

    Here is a simple test page which displays the behaviour:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
        <form id="form1" runat="server">
            <asp:ScriptManager runat="server" ID="ScriptManager1">
            <telerik:RadNumericTextBox ID="txtNum" ButtonsPosition="Right" MinValue="0" MaxValue="100" Type="Number" runat="server" ShowSpinButtons="true"   >
                <NumberFormat AllowRounding="false" DecimalDigits="2" />
                <IncrementSettings Step ="1" />











    partial class _Default : System.Web.UI.Page




    protected void Page_Load(object sender, EventArgs e)






  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Apr 2009 Link to this post

    Hi Antony,

    I tried your code and able to replicate the behavior. So I attached OnValueChanged event to RadNumericTextBox in order to reset the value to 2 decimal places. See the workaround which I tried. Hope this help you.

    <telerik:RadNumericTextBox ID="txtNum" ButtonsPosition="Right" MinValue="0" MaxValue="100" Type="Number" runat="server" ShowSpinButtons="true"   > 
        <NumberFormat AllowRounding="false" DecimalDigits="2" /> 
        <IncrementSettings Step ="1" /> 
        <ClientEvents OnValueChanged="OnValueChanged" /> 

    <script type="text/javascript"
    function OnValueChanged(sender, args) 
        var input = sender;   
        var number = input.GetValue().toString();    
        if(number.length - number.indexOf('.') > 3 && number.indexOf('.') > 0)    
            number = number.substring(0, number.indexOf('.') + input._numberFormat.DecimalDigits + 1);    

  3. Antony
    Antony avatar
    57 posts
    Member since:
    Oct 2008

    Posted 21 Apr 2009 Link to this post

    Thanks Shinu for your quick response.


    Can Telerik please confirm that this is a bug and give me some indication as to when it will be fixed.

    I am writing a brand new web application and if possible I would like to keep the "workarounds" to a minimum so I would prefer to wait for a bug fix if possible.

    Many thanks




  4. Answer
    Daniel avatar
    4949 posts

    Posted 21 Apr 2009 Link to this post

    Hello Antony,

    I confirm that we are aware of the aforementioned behavior - the issue is already added to our product backlog. I assure you that our developers will do their best to investigate the problem as soon as it is possible.

    Best regards,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top