0
Hello, I’m using the plugin masked input
to mask some fields of the kind decimal!
However, when I submit the form this field arrives as null in the class controller
. I’ve searched and I can’t find anything about it.
Could someone help me? Thanks in advance.
Follows the code.
Model
[Display(Name = "Telefone")]
public decimal? TELEFONE_FUN { get; set; }
Controller
[HttpPost]
public ActionResult Add_Funcionarios(FUNCIONARIOS funcionario)
{
if (ModelState.IsValid)
{
//recupera o nome do usuario da sessao
GRAgro.Models.USUARIOS usuario = (GRAgro.Models.USUARIOS)Session["usuario"];
string nome = User.Identity.Name;
// seta o id do usuario vindo da sessao
funcionario.ID_USU = UsuarioCont.PegaIdUsuarioLogado(nome);
FuncionarioRep.Add_Funcionarios(funcionario);
cadHistorico(historico, funcionario,"Cadastro do Funcionario(a):");
TempData["Feedback_cadastro"] = "Funcionario "+funcionario.NOME_FUN+" Cadastrado com Sucesso!";
return RedirectToAction("CadastradoComSucesso", "Feedback");
}
else
{
TempData["teste"] = "nao cadastrado";
return View();
}
}
View
<div class="form-group">
@Html.LabelFor(model => model.TELEFONE_FUN)
@Html.TextBoxFor(model => model.TELEFONE_FUN, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.TELEFONE_FUN)
</div>
Jquery
$("#TELEFONE_FUN").mask("(99) 99999-9999");
If you remove Mask, it arrives correctly?
– PauloHDSousa
Enough, so I’m intrigued, and when in my model the attribute is string it arrives in the normal controller, but masked
– Douglas
Where are you waiting for it to arrive on the model? You shouldn’t put a property in Action?
– PauloHDSousa
It arrives in the null controller action!
– Douglas