Is it possible to access the model in the PartialView returned by RenderAction from the parent view? I have a controller action that returns a view with a list of items that have geographical data. I'd like to use the lat/lon to place the items on a map as well, but I don't want to have to parse the html for the data.
Asked
Active
Viewed 94 times
0
-
How are you getting these geographical data? Why not put them on a service method then call it from your parent action method? – WannaCSharp Apr 23 '14 at 02:34
-
@WannaCSharp The short answer is separation of concerns. I know there are many ways to get the data. I am trying to keep the controllers and models separate where the data come from different sources and have different purposes. I was kinda hoping for a solution that just lets me composite data in the view (maybe with Javascript?) rather than counting on the controllers to mix data from multiple sources. Thanks for the suggestion, though. – Quasi_Stomach Apr 23 '14 at 16:22
-
`RenderAction()` was designed to be it's own *pipeline*, independent and unaware if the call was a real call or a ChildAction. Since all actions only render, I'd question your design. Otherwise you have a view the has a dependency on a RenderAction which is not good practice. Since you want data from your Action, I would rather see you pull all the data, and call a partial view instead. – Erik Philips Apr 23 '14 at 16:34
-
@ErikPhilips Thanks for your explanation of why that would be bad practice. I will do as you suggest. I guess I really didn't understand `RenderAction()`. – Quasi_Stomach Apr 23 '14 at 19:47