我发现编辑项目的可变长度列表的最好的建议是在2008年的ASP.Net MVC 2写入。
http://blog.stevensanderson.com/2008/12/22/editing-a-variable-length-list-of-items-in-aspnet-mvc/
是这种做法仍然是ASP.Net MVC 4最好的一个,或者是有要么是标准化的,或更优雅的一个较新的解决方案吗?
我发现编辑项目的可变长度列表的最好的建议是在2008年的ASP.Net MVC 2写入。
http://blog.stevensanderson.com/2008/12/22/editing-a-variable-length-list-of-items-in-aspnet-mvc/
是这种做法仍然是ASP.Net MVC 4最好的一个,或者是有要么是标准化的,或更优雅的一个较新的解决方案吗?
Take a look at http://knockoutjs.com/ it's a JavaScript framework that relies on the MVVM pattern. Basically you can data-bind array models to your HTML and then post them back as JSON arrays to your controller. One great side-effect is that it helps to make your controllers more unit-test friendly (because your controllers mainly return JSON).
There's a great video about knockout at http://channel9.msdn.com/Events/MIX/MIX11/FRM08
Basically what you want to look at is observable arrays. http://knockoutjs.com/documentation/observableArrays.html
I would also highly recommend you watch the 20 minute video introduction on knockout.js. Even though it's an older video it gives you a good idea of how it works, it helped me a lot. http://channel9.msdn.com/Events/MIX/MIX11/FRM08
You can also use AngularJS http://angularjs.org/ which is the same concept (MVVM), it is put out by google. There are a lot of differences between the two but the most major one (I noticed atleast) is in angular there is more reliance on templating, in a lot of respects it gives it more power.
Between the two I think knockout is easier to get up and running but you have more options with AngularJS.