What is the best way to make Add, Edit, Delete and List actions in one View
I'开发者_如何学编程m converting a huge web application from ASP.Net 3.5
to ASP.Net MVC3
and C# 4.0
using VS2010
, about 90% of site pages has Add, Edit, Delete, And List actions. If I create one view for each action that means each page will converting to 4 view (4 physical files) but I don't like that but I can do it if I have to. :(
My question is Is there an elegant way to converting one ASP.Net
page to one View
contains all required action?
You can create one view to do this. Each user action will route to a respective controller action via a form post. Inside the controller action the model will be updated and then the controller action will redirect to the view.
Personally, I wouldn't have an issue converting one page to four views if it is meaningful to do so in terms of maintenance. If they are similar in structure, a lot of the repetition can be abstracted out into Layouts, Partials and other views.
精彩评论