2
I’m going through a problem I’ve never seen before. I’m hoping someone has seen it and can help me.
I’m working with Asp.net mvc 5, and sending a form via post to my controller.
My model:
<div class="col-md-6">
<form action="@Url.Action("Create","DadosManuais")" method="get" class="form-horizontal">
meus campos aqui...
</div>
My controller:
public ActionResult Create(DadosManuaisCreate dados){
Algumas linhas de código...
}
I’m also using jquery to create the masks in the model:
@section Scripts{
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
$(document).ready(function () {
$("#periodo").inputmask("mm/yyyy");
$("#tacGestor").maskMoney({ showSymbol: true, symbol: "R$",
decimal: ",", thousands: "." });
$("#vlEsperado").maskMoney({ showSymbol: true, symbol: "R$",
decimal: ",", thousands: "." });
$("#vlAdquirido").maskMoney({ showSymbol: true, symbol: "R$",
decimal: ",", thousands: "." });
$("#selic").maskMoney({ showSymbol: true, symbol: "R$", decimal:
",", thousands: "." });
$("#premioSelic").maskMoney({ showSymbol: true, symbol: "R$",
decimal: ",", thousands: "." });
$("#seguro").maskMoney({ showSymbol: true, symbol: "R$",
decimal: ",", thousands: "." });
$("#despesas").maskMoney({ showSymbol: true, symbol: "R$",
decimal: ",", thousands: "." });
$("#naoIdentificados").maskMoney({ showSymbol: true, symbol:
"R$", decimal: ",", thousands: "." });
$("#qtdContratosAtivos").inputmask("9{1,3}.9{1,3}.9{1,3}");
});
</script>
}
Note that at the end of the jquery command, there is a parameter "thousands: "." }"
This says that for thousands, the point (".") will be used to divide.
My problem happens when I press the Ubmit button. Object is instantiated by parameter in the controller, but fields containing numbers greater than 999.99 are reset.
Look at you:
I removed the parameter "thousands: "." }" and the problem stopped occurring:
How to get around this problem without having to remove my mask?
Most grateful!
PS: No data posted here is real. They are all used to simulate a system insertion.
I was able to understand what might be going on, but it didn’t work :(. The script seems to be running after the controller code. I remember it previously worked, but something I changed made the data start to be zeroed.
– Csorgo
@Csorgo edited the answer, there must be another way to solve this, but for now it must work like this.
– Lucas
Not yet :( Is there a solution in the back end in c#?
– Csorgo
@Csorgo all the inputs have a
name
corresponding to a class property ?– Lucas
Yes @I Dunno. The id too. I don’t know if there is any conflict between them, but I put to avoid many different references to the same element.
– Csorgo