Passing "text" numbers into PreEdit with german format

Passing "text" numbers into PreEdit with german format

airmasterairmaster Posts: 72Questions: 15Answers: 2

I am trying to pass a number in german format, "5,7" which in the US is 5.7 (CurrencyConversionUSD). I need to do some math on it before saving it, and want to do it on the server side for various reasons, the last one being that if I do it on the client side it doesn't look good as the number changes in the dialog just before the submit, so a "5,7000" becomes "57000".

The problem is that the value has the "," stripped out from it:

                editor.PreEdit += (sender, e) =>
                {
                    Dictionary<string, object> tblWinLoss = (Dictionary<string,object>)e.Values["tblWinLoss"];
                    string stringCurrencyConv = tblWinLoss["CurrencyConversionUSD"].ToString();
                        ...
              }

I am not sure how delegates work, but I noticed in the form post that it does copy over the %2c represeting the comma.

I could use some guidence.

Answers

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    it doesn't look good as the number changes in the dialog just before the submit, so a "5,7000" becomes "57000".

    I'm afraid I don't know why that would happen. Are you using a plug-in for the input, or some other formatter? It isn't something that Editor itself would do (changing the format of an input immediately upon submit).

    Are you able to give me a link to the page showing the issue please?

    Thanks,
    Allan

  • airmasterairmaster Posts: 72Questions: 15Answers: 2

    The website is internal, so I can't show the issue. I did determine that the sumitted POST does have the "," in it. When it reaches the MVC server, the "," gets stripped out.

    Looking at the received object (e), for the given key, it has the type object {decimal}, so I thought I would be able to fix it with a custom model binder for decimals.

    That isn't working though.

  • airmasterairmaster Posts: 72Questions: 15Answers: 2

    Allan,

    I wrote a standalone VS project that will create a localdb (codefirst) and will illustrate my problem. I sent it in a private message along with a zipped project file. This was from scratch, so no additional plugins.

This discussion has been closed.