tags:

views:

206

answers:

2
+2  Q: 

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 partial page htmlhelper.ViewData["myData"] is null.

+3  A: 

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.

Andrew
how to pass it to the subaction ?
santose
The same as if you were calling another action from the view ... Something like:Html.RenderAction("SomeAction", new { id = 1, param2 = "something, param3 = "something else" })
Andrew
A: 

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.

santose