MVC 5 strongly Typed views (strongly typed view)

Source: Internet
Author: User

Learning MVC has long been found that many MVC videos or articles on the site use strongly Type views to interact with the controller and view. Insus.net's previously published blog posts are also heavily used in this way:

The DataTable data is shown in the MVC application http://www.cnblogs.com/insus/p/3361182.html
MVC uses non-Entity Framework to display data in view http://www.cnblogs.com/insus/p/3364235.html
MVC uses non-Entity Framework to display data in view (ii) http://www.cnblogs.com/insus/p/3364482.html
"MVC shows detailed records without Entity Framework" http://www.cnblogs.com/insus/p/3366608.html
Even in this article, "MVC 5 display, creation, editing, deletion and other functions practice" http://www.cnblogs.com/insus/p/3372916.html also listed.


Whenever you use the @model xxx.xxx.Models.xxx syntax in a view. Note that the model followed by @ is full of lowercase letters.
Insus.net Think Razor is interesting, the properties of all models in the view are dynamic, we don't have to know the actual type, and we can use the model key of @ to represent the type name of the model.

Let's make a simple example of creating a model in the models directory:



If you don't see or step, you can refer to the following animation:



To create a fruit controller, you can refer to step:



Opens another Add Scaffold window:



Modify write specifies a controller name:



You can also see the complete implementation process:



OK, it's time to implement the view,



Also see real-time operation, and run the final result:



  Use strongly typed view, Is the default method for MVC. Each time you create a view, the insus.net chooses empty template. In fact, you can choose the corresponding template according to the actual situation, let it automatically generate:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.