On my homepage, there is a shortcut button that opens a modal, and within that modal it has a partialView that points to an action within another controller . Until then calm down.
<div class="modal fade" id="modalCreate" tabindex="-1" role="dialog" aria-labelledby="createClasseModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
@Html.Action("Create","Classes")
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</div>
</div>
</div>
</div>
When opening the modal with partial view being displayed correctly for inclusion of the information. After the inclusion, the routine executes savechanges
correctly in controller , then it gives RedirectToAction
to return to the home screen.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "id,descricao,dia_1,dia_2,horario,dt_inicio,dt_termino,sala,limite_max,limite_min,preco,status,professor")] Classe classe)
{
ViewBag.professor = new SelectList(db.Pessoa, "id", "nome", classe.professor);
if (ModelState.IsValid)
{
db.Classe.Add(classe);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(classe);
}
In debug it returns to index
, and at the moment of redrawing the screen with modal, it accuses the error:
Does anyone have any ideas for fixing this?