Is there a way to access a .NET MVC ViewBag's properties using a string key?
I have a value 开发者_如何学运维that I've put in the ViewBag:
ViewBag.SomeKey = value;
In my view I have the key stored as a String.
String theKey = "SomeKey";
Is there a way to access my value from the Viewbag using this String version of the key?
Use ViewData[theKey]
. Both ViewData
and ViewBag
use the same underlying storage.
精彩评论