// Renders the partial view which will be shown in a modal public ActionResult Modal(string selectedValue) { var model = new DialogViewModel { Prop1 = selectedValue }; return PartialView(model); }
public ActionResult Modal(DialogViewModel model) { if (ModelState.IsValid) { // validation of the modal view model succeeded => // we return a JSON result containing some precalculated value return Json(new { value = string.Format("{0} - {1} - {2}", model.Prop1, model.Prop2, model.Prop3) }); } // Validation failed => we need to redisplay the modal form // and give the user the possibility to fix his errors return PartialView(model); }