KeepTrailingZerosOnFocus NumericTextBox

5 posts, 0 answers
  1. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 24 Feb 2012 Link to this post

    I want the same property behavious set to false but On NOT Focus. If I have 100 it will show 100.00 on no focus and 100 on focus... I want 100 on both. Is that possible? But I want to show the 2 digits if it's not .00

    Thanks
  2. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 27 Feb 2012 Link to this post

    Nobody can help me?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 27 Feb 2012 Link to this post

    Jocelyn:

    Take a look at this forum thread which covers your issue in depth: Feature Request : Numeric Textbox & Trailing Zeros.

    If I understand your requirement, you should be able to use the "NumericTextBox1.NumberFormat.DecimalDigits = 0;" setting to trim the trailing "0"s. See Formatting Numeric Values

    Hope this helps!
  5. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 02 Mar 2012 Link to this post

    I tried what the guy said. It is not working for me.

    When I try this is debug:

    function PoidsTaille_OnValueChanged(sender, eventArgs)
    {
        var v = eventArgs.get_newValue().toString();
        sender._textBoxElement.value = v;
        PoidsTaille_Changed(sender._clientID, eventArgs.get_newValue());
    }

    It removes the trailling zeros, but when this function is done, the trailling zeros come back... In debug, zeros come back when this.updateDisplayValue()  is called.
  6. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 05 Mar 2012 Link to this post

    Hi Jocelyn,

    You could override the get_displayValue function that is used for generating the display value and apply your custom format instead of using these from the Telerik.Web.UI.NumberFormat.
    Here is an example:
    <script type="text/javascript">
       Telerik.Web.UI.RadNumericTextBox.prototype.get_displayValue = function ()
       {
         var value = this.get_value();
         return value.toString(); //or apply your custom format here
       }
     </script>
     <telerik:RadNumericTextBox runat="server">
     </telerik:RadNumericTextBox>


    Kind regards,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017