I have a form and in this form I have fields that are from a Model.
The form is a modal-dialog from bootstrap. When i click on the submit button all fields must be valid. This works!
Now i want to close the modal and refresh the page if the Model Validation is valid. Only the code does first the Ajax call and then the ModelState.IsValid
in the Controller.
Ajax:
$('#addAlertModal form').submit(function (e) {
//TODO: if ModelState.IsValid in Controller
refreshAlerts();
closeAlertModal();
});
Does somebody know what i can do about this? Or is this not possible?
EDIT:
Or is it possible to call Ajax functions inside the if
:
@if (ViewData.ModelState.IsValid) {
//Call here the functions
refreshAlerts(); //Error: The name 'refreshAlerts' does not exist in the current context
}