Passing objects from host view to PartialArea in MVC
Consider the MvcContrib sample for PartialArea's. In the Home/Index view a call is made to the PartialArea 'QuickLinks' extension method to render it's content: Html.RenderQuickLin开发者_开发技巧ks().
What I'd like to so is something similar to this, but have the host view pass the actual links to be rendered by the PartialArea from the host view model. Maybe something like: Html.RenderQuickLinks(Model.Links)?
Is this possible? And what do I need to do to arrange this?
If I understand this right, as long as the information is in your ViewModel and you implement a partial view called via html.Partial then your viewmodel will automatically be sent to your child view model. Otherwise you can pass the specific data in ViewBag ViewData or if you need this on a second request TempData.
精彩评论