开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜