title: Nested forms in ASP.NET MVC
body: <p>I have a shopping cart where the following are true:</p>
  
  <ul>
  <li>There is one "Remove" button for each product in the shopping cart</li>
  <li>There is one editable quantity text box for each product in the shopping cart</li>
  <li>There is one "Update" button for the entire shopping cart</li>
  </ul>
  
  <p>The idea is that the user can modify the quantities for each product in the cart and click "Update" to commit the changes.</p>
  
  <p>How would you program the "Update" button using MVC? Would you wrap the entire shopping cart in a form that posts back to itself and somehow locate the quantity values in the FormCollection? The problem with that approach is that since the "Remove" buttons each live in their own forms I would now be doing nested forms on the page and I am not even sure that is allowed.</p>
  
  <pre><code>        &lt;% using (Html.BeginForm("Index", "Cart")) { %&gt; 
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;th&gt;&amp;nbsp;&lt;/th&gt;
              &lt;/tr&gt;
          &lt;% foreach (var item in Model) { %&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;input name="qty" type="text" value="&lt;%=item.Quantity%&gt;" maxlength="2" /&gt;
                      &lt;% using (Html.BeginForm("RemoveOrderItem", "Cart")) { %&gt;                       
                          &lt;%= Html.Hidden("ShoppingCartItemID", item.ShoppingCartItemID) %&gt;
                          &lt;input name="add" type="submit" value="Remove" /&gt;
                      &lt;%} %&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;% } %&gt;
          &lt;/table&gt;
  
          &lt;input name="update" type="submit" value="Update" /&gt;
          &lt;%} %&gt;  
  </code></pre>
  
  <p>How would I incorporate the bottom input into this form?</p>