MVC 2 RenderAction
Im having a value in ViewData, lets say htmlhelper.ViewData["myData"]="some";
And in partial page I can overwrite the myData's value.
But when I using the Html.RenderAction() and call a partial page.
In the same part开发者_开发技巧ial page htmlhelper.ViewData["myData"] is null.
When you call RenderAction, you create an entirely new ViewData instance for your partial page. If you want ViewData["myData"] to be visible by your other action, either pass it to the subaction or put it in TempData.
I figured out from MVC source code. Cool that we have MVC as open source.
htmlHelper.ViewContext.HttpContext.Items["myData"]
this will maintain the value from Partial and RenderAction case.
精彩评论