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

[Solved] CurrencyTextBox wrong display value

3 Answers 107 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrea Tasca
Top achievements
Rank 1
Andrea Tasca asked on 28 Apr 2011, 03:32 PM
I'm using the CurrencyTextBox inside a EditorTemplate:

Decimal.ascx:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<decimal?>" %>
<%= Html.Telerik().CurrencyTextBox()
        .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
        .InputHtmlAttributes(new { style = "width:100%" })
        .Value(Model)
        .CurrencySymbol(" ")
%>

the real value is 1.0 but the display value is 10.00. The problem is, when I save, the real value become 10.0 and the display value 100.00 and so on..
 
I believe there is a problem with the culture, I'm using it-IT, and the decimal numbers become part of the real number.

how can I fix it?

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 28 Apr 2011, 05:01 PM
Hello Andrea,

 
Could you please verify that the globalization is turned on? Check this help topic for more information.

If the problem still persists I will ask you to send a simple test project which shows the depicted issue.

Kind regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andrea Tasca
Top achievements
Rank 1
answered on 28 Apr 2011, 06:06 PM
with the latest build the problem seems fixed, but now the javascript validator is blocking the value because there are a wrong decimal separator..
0
Georgi Krustev
Telerik team
answered on 29 Apr 2011, 09:17 AM
Hello Andrea,

 
This is expected behavior. The problem is caused by the inability of the jquery.validate.js to validate globalized numbers. Hence in order to avoid this erroneous behavior you will need to add custom "range" validate method, like so:

@( Html.Telerik().ScriptRegistrar().jQuery(false).Globalization(true)
       .DefaultGroup(group => group.Add("jquery.unobtrusive-ajax.min.js").Add("jquery.validate.js").Add("jquery.validate.unobtrusive.min.js"))
       .OnDocumentReady(
            @<text>
                $.validator.addMethod("range", function( value, element, param ) {
                    var parsedValue = parseFloat(value.replace($.telerik.cultureInfo.numericdecimalseparator, '.'));
  
                    return this.optional(element) || ( parsedValue >= param[0] && parsedValue <= param[1] );
                })
            </text>
        )
)

Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
NumericTextBox
Asked by
Andrea Tasca
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Andrea Tasca
Top achievements
Rank 1
Share this question
or