When inside a razor view, can you pass data to the view from a child action? IE:
@{
ViewBag.passedData = "";
}
@Html.Action("ChildView","ChildController") // Inside the child action (controller or view) magic happens
@ViewBag.passedData // it's not empty!
Note that inside child view, I can read the parent view data using ControllerContext.ParentActionViewContext.ViewBag.passedData
but when I write to it, nothing happens.
Turns out that to access the .passedData property, one should use in the parent View:
@ViewContext.ViewBag.passedData // Has the passed data!
@ViewBag.passedData // null
This will get the ball rolling but if there is a more proper or formal way to do this please reply.