In short... Use the controller's view bag.
ViewContext.Controller.ViewBag.MyVar = "myVal";
and
@ViewContext.Controller.ViewBag.MyVar
===============================================================
There is good information here: http://forums.asp.net/post/4254825.aspx
===============================================================
Generally, ViewData["StoreName"] is same as ViewBag.StoreName
Also, Controller.ViewData["StoreName"] = Controller.StoreName =
ViewContext.Controller.ViewBag.StoreName
=ViewContext.Controller.ViewData["StoreName"]
But every view and partial view gets its own instance of viewdata.
http://jeffreypalermo.com/blog/viewdata-mechanics-and-segmentation-excerpt-from-asp.net-mvc-in-action/
===============================================================
There is a another solution here: https://stackoverflow.com/a/4834382/291753
===============================================================
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…