I have a MVC project, on one page, when clicked a link, it pops a modal dialog which has some buttons on it. One button is for adding a new user. If there is ModelState error, it should show the error in the Modal Dialog. How can I do that?
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> AddNewUser(RegisterViewModel model)
{
if (ModelState.IsValid)
{
......
}
// If we got this far, something failed, redisplay form in Modal Dialog
// what should return here?
}
I searched, it seems we have to make a ajax call to validate the ModelState.
Is there any other ways instead of this? Thanks