码迷,mamicode.com
首页 > Web开发 > 详细

Part 3 ViewData and ViewBag in mvc

时间:2015-10-05 20:42:41      阅读:256      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!