Three common ways to pass values ​​in MVC pages? ViewData, ViewBag, TempData_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:53:35
Original
1676 people have browsed it


I have been exposed to MVC code a lot recently, and I have discovered a lot of new things, such as page value transfer. I discovered that there are so many objects in MVC that can be used to transfer values. I have used ViewData and ViewBag in the past two days, and then associated them with TempData. Now I will make a table for comparison:



 





After using it, I personally feel that ViewBag is the best to use. Direct attribute assignment is enough, but ViewData and TempData have their advantages. When used, you can transfer data from Controller to Views according to the size of the data. The data is passed inside, or the Controller passes the data. . . Make a decision after considering various factors.




In addition to these three common ones, there is another one that I want to mention, that is When using model, you only need to access the properties. In addition, it is like UpdateModel and ViewModel. . . I won’t talk about some things that I haven’t used yet. I’ve been a little busy recently, so I’ll just try to find enough to use them for the time being. I’ll add them to this article when I use them.







                            If there are any missing parts, please leave a message, thank u~





 






source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!