0
I have a simple registration screen that, when selected new record, is opened a modal (which is a partialview in the project) for the user to inform the fields for registration.
The view call is performed through Jquery:
$("#btn-Incluir").click(function () {
$("#modalCadastro").modal({
backdrop: 'static',
keyboard: true
}, 'show');
});
The save button of Partialview is the type submit
, and inside my controller have the method below:
public virtual ActionResult Salvar(TViewModel model)
{
if (ModelState.IsValid)
{
if (model.Operacao.Equals("I"))
Inserir(model);
else
Atualizar(model);
return RedirectToAction(NmView);
}
else
{
return PartialView(model);
}
}
The problem is that when the ModalState
is invalid, error is displayed below:
The partial view 'Save' was not found or no view engine Supports the searched Locations. The following Locations Were searched
If I change and return and pass the path of mine partial view, the system displays only the partial view, no longer as modal daughter of the main page.
How do I make that when the ModalState
is invalid, continue with modal open and only present errors on page via ValidationMessageFor
.
Thank you!
There is a Partialview calling for
Salvar.cshtml
within the subdirectories corresponding to its Controller which is inside the directoryViews
?– Leonel Sanches da Silva
No. Save is just a method within my controller, which returns a result action.
– Carlos Henrique Biazin Esteves