In a form, I have one row type decimal, it is defined with decimal(18,2), when save data to server (windows server 2016 and sql server 2017) the row is desajust, p.e. I send 5907.50 and save 590750.00
I have doing proof in different windows server, in a one it work fine but in the production not.
It looks like the the decimal is missing when the form is submitted. This can be due to culture settings. You'll need to debug. Otherwise, post code that reproduces this issue.
When you speak of culture settings it is refered to server or cliente when i fill form?
HTTP is a text based protocol. ASP.NET Core provides model binding which automatically converts text inputs into proper types like a decimal value. Your description indicates the decimal is lost or ignored causing 5907.50 to become 590750. Culture
setting affect how numbers and dates are formatted which can affect the model binding.
But I'm just guessing because I cannot see your code or reproduce this issue. Can you shared the code or a sample that reproduces this issue?
I think you need to take a closer look at your code. The code shared to this point has far too many potential problems. It looks like the View has many Pago records but moto is always going to be the first #moto found in the DOM.
Venta is a class with other classes, this contain class for Pago, Concepto etc.
But, in th view I send only a regiter of Pago, is in this when monto is desajust. For this, Pago[0].monto is declared, because always send one Pago in this place. The problem is that desajust the value monto, p.e. 1950.50 change to 195050.00, but it is an
error.
None
0 Points
7 Posts
Decimal net core
Jul 24, 2019 07:10 PM|developer.chiapas|LINK
I have a project in net core 2.2.
In a form, I have one row type decimal, it is defined with decimal(18,2), when save data to server (windows server 2016 and sql server 2017) the row is desajust, p.e. I send 5907.50 and save 590750.00
I have doing proof in different windows server, in a one it work fine but in the production not.
Any idea from this error.
Help me!!
All-Star
43841 Points
18766 Posts
Re: Decimal net core
Jul 24, 2019 07:35 PM|mgebhard|LINK
It looks like the the decimal is missing when the form is submitted. This can be due to culture settings. You'll need to debug. Otherwise, post code that reproduces this issue.
None
0 Points
7 Posts
Re: Decimal net core
Jul 24, 2019 07:49 PM|developer.chiapas|LINK
Hi, thanks for response.
When you speak of culture settings it is refered to server or cliente when i fill form?
Because, in other server work fine.
All-Star
43841 Points
18766 Posts
Re: Decimal net core
Jul 24, 2019 08:20 PM|mgebhard|LINK
HTTP is a text based protocol. ASP.NET Core provides model binding which automatically converts text inputs into proper types like a decimal value. Your description indicates the decimal is lost or ignored causing 5907.50 to become 590750. Culture setting affect how numbers and dates are formatted which can affect the model binding.
But I'm just guessing because I cannot see your code or reproduce this issue. Can you shared the code or a sample that reproduces this issue?
Everyone on the forum makes this statement.
None
0 Points
7 Posts
Re: Decimal net core
Jul 24, 2019 08:57 PM|developer.chiapas|LINK
The model is:
In the View has the follow code:
I use jquery for send via ajax to controller:
Inside function registrarCobro get value for monto with:
And, in the controller i have follow code:
All-Star
43841 Points
18766 Posts
Re: Decimal net core
Jul 24, 2019 09:08 PM|mgebhard|LINK
What is the class definition for Venta?
None
0 Points
7 Posts
Re: Decimal net core
Jul 24, 2019 09:17 PM|developer.chiapas|LINK
All-Star
43841 Points
18766 Posts
Re: Decimal net core
Jul 24, 2019 09:26 PM|mgebhard|LINK
Where is the IList<Pagos> populated?
I think you need to take a closer look at your code. The code shared to this point has far too many potential problems. It looks like the View has many Pago records but moto is always going to be the first #moto found in the DOM.
None
0 Points
7 Posts
Re: Decimal net core
Jul 24, 2019 10:14 PM|developer.chiapas|LINK
Venta is a class with other classes, this contain class for Pago, Concepto etc.
But, in th view I send only a regiter of Pago, is in this when monto is desajust. For this, Pago[0].monto is declared, because always send one Pago in this place. The problem is that desajust the value monto, p.e. 1950.50 change to 195050.00, but it is an error.
None
0 Points
7 Posts
Re: Decimal net core
Jul 25, 2019 01:55 AM|developer.chiapas|LINK
tests done so far, with jquery:
monto=5907.50
parseFloat(monto) ----> save the value 59075.00
parseFloat(monto)
.toFixed(2) --> save the value 590750.00
None
0 Points
7 Posts
Re: Decimal net core
Jul 25, 2019 04:22 AM|developer.chiapas|LINK
I solucioned the problem, after of test many times, i used the follow code in jquery:
applicate a mask :)