What is the best way to handle duplicate forms in MVC?

The best public example I can think of with my head would be an Amazon shopping basket. If you have a page that displays several different entries that may contain several different fields.

I can’t put each in the form tag because the user can change several entries and then submit.

I can’t just update all the records that I return, because:
1. Performance
2. Audit
3. If someone changed the record that the user “did not change” when they viewed the page, and then the user posted these changes, there will be overwritten.

So, what is the best way to process the data and then get which records have changed from this?

It is clear?

+5
source share
3 answers

Use binding! Do not repeat the collection of the form in your actions.

Steve Sanderson wrote a post on how to do this. I wrote a post on how to do this using MvcContrib FluentHtml . Both posts are very verbose and include downloadable code.
+3
source

, . . - . , , , , .

JavaScript , , , ; ( , / ).

+1

( ) , , js - , , , .

and as Eric said, you can use hidden form elements to make sure it works without js.

+1
source

All Articles