Reputation: 168
How can I call and render a view of controller from action of another controller. I have this, an action of Product Controller :
public ActionResult SortedLists(List<string> items, string ShopID)
{
//Do sth...
db.SaveChanges();
return RedirectToAction("Index", "ControlPanel", new { ID = ShopID });
}
And Index is the action(view) of ControlPanel Controller :
public ActionResult Index(int ID)
{
ViewBag.theRelatedShopID = ID;
return View();
}
How can I render Index and display it in browser???
Upvotes: 0
Views: 1994
Reputation: 1038710
public ActionResult SortedLists(List<string> items, string ShopID)
{
//Do sth...
db.SaveChanges();
return View("~/ControlPanel/Index.cshtml", (object)ShopID);
}
Here we are passing the ShopId
as model to the Index view. If this view is strongly typed to some model you should pass this model:
MyViewModel model = ...
return View("~/ControlPanel/Index.cshtml", model);
Upvotes: 2