i have the following action method, that returns a partial view `_create`. but is there a way to pass a Json object such as `return Json(new { IsSuccess = "True" }, in addtion to the Partial view. Part of my Action method looks as follow:-
try
{
if (ModelState.IsValid)
{
var v = repository.GetVisit(visitid);
if (!(v.EligableToStart(User.Identity.Name)))
{ return View("NotFound"); }
vlr.VisitID = visitid;
repository.AddVisitLabResult(vlr);
repository.Save();
ViewBag.LabTestID = new SelectList(repository.FindAllLabTest(), "LabTestID", "Description", vlr.LabTestID);
// return Json(new { IsSuccess = "True" }, JsonRequestBehavior.AllowGet);
@ViewBag.status = "Added Succsfully";
return PartialView("_create",vlr) ;
}
}
johnjohn1231...
Participant
922 Points
871 Posts
Can i return a Partial view and a Json object from my action method at the same time
May 02, 2012 11:54 PM|LINK
i have the following action method, that returns a partial view `_create`. but is there a way to pass a Json object such as `return Json(new { IsSuccess = "True" }, in addtion to the Partial view. Part of my Action method looks as follow:-
try { if (ModelState.IsValid) { var v = repository.GetVisit(visitid); if (!(v.EligableToStart(User.Identity.Name))) { return View("NotFound"); } vlr.VisitID = visitid; repository.AddVisitLabResult(vlr); repository.Save(); ViewBag.LabTestID = new SelectList(repository.FindAllLabTest(), "LabTestID", "Description", vlr.LabTestID); // return Json(new { IsSuccess = "True" }, JsonRequestBehavior.AllowGet); @ViewBag.status = "Added Succsfully"; return PartialView("_create",vlr) ; } }BR