0

So I'm trying to add a partial view to my main view in MVC3, but the partial view needs new data. Instead of expanding the view model that has the necessary data in the main view and then passing it along to the partial view, is it possible to specify a controller action that directly feeds the partial view with the necessary model?

For example something like:

@Html.Partial("_PartialView", Controller, Action, Parameters)

Thanks in advance.

Jay Sun
  • 1,583
  • 3
  • 25
  • 33
  • probably it was discussed on stackoverflow: [asp.net MVC partial view controller action](http://stackoverflow.com/questions/1371031/asp-net-mvc-partial-view-controller-action) – Samich Sep 01 '11 at 19:40
  • It wasn't. All that does is pass a model that was already supplied to the main view down to the partial view. I want the partial view to get a separate model from a different controller and action. – Jay Sun Sep 01 '11 at 19:43

1 Answers1

1

In a limited sense, yes.

The only thing you can do is send the current model over to another action through Html.Action Besides that you either need to add it to TempData, or pass what's required in the querystring through your GET parameters OR use an ajax request where you write these values to an html form and serialize that to your new page, but thats a hack : )

Adam Tuliper
  • 29,982
  • 4
  • 53
  • 71
  • My coworker suggested an Ajax request as well, but it makes no sense to make two calls to the server when you can do it in one. But I guess you already knew that. So how would you do it with an Html.Action? – Jay Sun Sep 01 '11 at 19:56