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

[Solved] Handling updates with non en-US numbers and NumericTextBox

1 Answer 88 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.
Jesse
Top achievements
Rank 1
Jesse asked on 04 Nov 2010, 08:19 PM
I am guessing this issue is not unique to Telerik NumericTextBox and my knowledge of asp.mvc is still limited so maybe the solution is really straight forward?

The scenario: Logged on user is fr-FR culture so numbers are displayed / entered using comma instead of period for decimal 
example 5.55 (en-US) vs 5,55 (fr-FR)

when the from is submitted the values come across still in the logged on users format, makes sense because this is just a HTTP Post of all the form data and those input text have data with a comma

given 2 Telerik NumberTextBoxes on my form Hours_1, Hours_2
logged on users enters data
Hours_1: 1,11
Hours_2: 2,22

then an update action in the controller
public ActionResult Update(string Hours_1, double? Hours_2)
{
    System.Diagnostics.Debug.Write(Hours_1); // 2,22
    System.Diagnostics.Debug.Write(Hours_2); // null
      
    return null;
}

notice when I specify that it will be a double vs a string it becomes null
it would be nice if there was an easy way to transform from the logged on users format before the action executed

one work around is that if the form is submitted using ajax I can retrieve the 'real' value using the clientside api
$('#Hours_2').data('tTextBox').value();

it would be nice to not be forced into using an ajax submission

does anyone have experience with this same issue?

Thanks,

- Jesse

1 Answer, 1 is accepted

Sort by
0
Jesse
Top achievements
Rank 1
answered on 11 Nov 2010, 01:24 AM
It turns out this issue was due to setting the threads culture too late, it needs to be done in Application_BeginRequest

doing it in an Action Filter seems to be too late
Tags
NumericTextBox
Asked by
Jesse
Top achievements
Rank 1
Answers by
Jesse
Top achievements
Rank 1
Share this question
or