星空网 > 软件开发 > ASP.net

Part 3 ViewData and ViewBag in mvc

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

关键词:ie

ie
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流