0
I’m trying to get the value of a Hidden input inside the Controller by Formcollection, but the value is reset. To increase the value, I’m using a Javascript function.
HTML:
<form id="adicionarTituloManual" action="~/Movimento/AdicionarCodevedoresTit" method="post">
<input type="hidden" id="qtd" name="qtd" value="" />
</form>
Javascript:
function novo(i)
{
var form, quant;
var qtd = document.getElementById('qtd').value
if (qtd == 0) {
document.getElementById('qtd').value = i;
}
else{
i = parseInt(document.getElementById('qtd').value) + 1;
document.getElementById('qtd').value = i;
}
}
Controller:
public ActionResult AdicionarCodevedoresTit(FormCollection formCollection)
{
if (Session["usuario"] == null)
{
return Redirect("~/Home/Index");
}
else
{
this.usuario = (STLoginUsuario)Session["usuario"];
}
int qtd = HUtils.ConverteEmInteiro(formCollection["dvQtd"]);
return Redirect("~/Movimento/AdicionarCoDevedor");
}
The key to the Formcollection should be
qtd
and notdvQtd
. Right?– Jéf Bueno
You’re right! Thank you!
– Germano Sampaio