首页 > Web开发 > 详细

Part 3 ViewData and ViewBag in mvc

时间:2015-10-05 20:39:54      阅读:295      评论:0      收藏:0      [点我收藏+]

ViewBag and ViewData is a mechanism(机制) to pass data from controller to view.

We use ‘@‘ symbol(符号) to switch between html and C# code.

Both ViewData and ViewBag are used to pass data from a controller to a view.

ViewData is a dictionary of object that are stored and retrieved()取回 using strings as keys.

ViewBag uses the dynamic feature that was introduced in to C#4. It allows an object to have properties dynamically added to it.

Both ViewData and ViewBag does not provide compile time error checking. For example, if you mis-spll keys or property names, you wouldn‘t get any compile time error. You get to know about the error only at runtime. Internally ViewBag properties are stored as name/value pairs in the ViewData dictionary.

 

Part 3 ViewData and ViewBag in mvc

原文:http://www.cnblogs.com/gester/p/4856154.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!