1
I’m making a mini registration system, it has the place to edit a client’s registration, when I click edit it comes the data in the fields for me to edit, all fields comes normal, except the field date that comes empty.
I was seeing that in front-end the value comes in the tag value, but it does not appear in the system.
Edit controller:
// GET: Cliente/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
ClienteModel clienteModel = db.Clientes.Find(id);
if (clienteModel == null)
{
return HttpNotFound();
}
return View(clienteModel);
}
// POST: Cliente/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "IdCliente,Nome,DataNascimento,Sexo,CEP,Logradouro,Complemento,Bairro,Estado,Cidade,Numero")] ClienteModel clienteModel)
{
if (ModelState.IsValid)
{
db.Entry(clienteModel).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
}
data-birth field input(I am using Razor):
<div class="form-group">
@Html.LabelFor(model => model.DataNascimento, "Data-Nascimento", htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-10">
@Html.EditorFor(model => model.DataNascimento, new { htmlAttributes = new { @class = "form-control col-md-3", placeholder = "DD/MM/AAAA", id = "datanascimento", OnBlur = "verificarDataNascimento(datanascimento.value)" } })
@Html.ValidationMessageFor(model => model.DataNascimento, "", new { @class = "text-danger" })
</div>
</div>
Can someone tell me if I’m doing something wrong ?