开发者

Specify in controller code which partial a view will render

开发者 https://www.devze.com 2023-02-25 01:56 出处:网络
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

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号