Specify in controller code which partial a view will render
I have a RegisterView
, used for three different actions. Until now it was only used for two, and I have a FormVisible
flag on my view model that the controller sets for the first action, which uses the visible form to collect user details. On the second action, confirming the registration, the details form is not visible.
I now have two sets of details to collect, so instead of a boolean decision of whether on partial view must be rendered or not, I need a way for the controller to specify whic开发者_运维百科h partial view to render. How can I do this?
have not tried this, but you can pass the name of the partial view in either the view model or the ViewBag, then use that in your view to render the partialview
in the controller: ViewBag.PartialView = "PartialViewA";
in the view:
@Html.RenderPartial(ViewBag.PartialView)
精彩评论