I have a field in db named 'loss' which is of type float.
Here is how I save it in db:
[HttpPost]
public int SaveLoss(float loss)
{
var t = (from x in db.tblTest
where x.id == 8
select x).First();
t.loss = loss; //also tried t.loss = loss / 1;
db.SaveChanges(); //entity framework
}
This is how I always work and in all the other tables it works fine.
I enter the loss via a textbox and here is the Ajax call:
$.ajax({
type: "POST",
url: "/Test/SaveLoss",
data: {
loss: parseFloat($('#myTextbox').val().replace(',', '.'))
}
....
If in the textbox I enter 66.55, everything works great. If in the textbox I enter 66,55, the value stored in db is 6655. This issue doesn't happen on my computer. When I publish the application on server, it occurs. Why is this annoying issue happening and how to fix it?
Fiddler says that 66.55 is input parameter of SaveLoss.