Part 3 ViewData and ViewBag in mvc
2015-10-05 19:28
127 查看
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.
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.
相关文章推荐
- 不懂
- 高效能人士的起个习惯
- <七>账号管理
- 【Leetcode算法】- Add Binary
- ZOJ3819 ACM-ICPC 2014 亚洲区域赛的比赛现场牡丹江司A称号 Average Score 注册标题
- 黑马程序员—常见API
- EffectiveC#1--尽可能的使用属性(property),而不是数据成员(field)
- Centroid - SGU 134(树的搜索)
- 前景提取--Subspace learning models
- why delete Scene crash!
- iOS编程------- UITableViewController
- POJ3573(模拟)
- C#删除和清空文件夹的程序
- CodeForcesGym 100753E Change of Scenery
- [转]Android中自定义checkbox样式
- 分享一下我电脑里的软件
- PL SQLDEVELOPMENT导出数据库脚本
- 无题(四):分割字符串(运用二维数组)
- 优化Myeclipse10 Building Workspace速度慢等
- 关于Trimmomatic