简体   繁体   中英

A reusable CRUD view in MVC

Is it possible to create a set of views that will allow creation updating deleting an viewing any Model ?

In each ViewModel we already place data annotation and validation attributes and so on.. seems that it is not that far away to create a view that by reflection could go thought the Model Type get all the information an create a form.

Dose anything like that exists ?

Have you tried using an editor template:

@Html.EditorForModel()

And to have the editor template descend recursively into your complex view model properties you could write a custom editor template for the Object type as Brad Wilson explains in this blog post (look at the Shallow Dive vs. Deep Dive section towards the end of the article which covers this).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM