I’m reading Steven Sanderson’s book Pro ASP.NET MVC 2 Framework.
In his book, he use multiple web forms on a single web page to list products from database and provide Add to cart functionality.
When should I take this approach vs having single web form and using jquery selectors to add certain products to shopping cart?
Thank you for your help!
This allows you to limit the data you post back so that it’s relevant only to the Model you’re updating. In the case of that book, each item in the list corresponds to a list item in the Model. So to answer your question, any time you have an item on your page that represents something in your Model, if you need it to have form behaviour (e.g. you need to submit its data), wrap it in form tags.
If you were using jQuery selectors to post the selected items contained within a single form, it would effectively be the same thing with just a bit more work to inspect each element and post the selected items.