Ajax.BeginForm inside Html.BeginForm

后端 未结 2 1943
不知归路
不知归路 2020-12-31 07:50

I have a view that is used for editing stuff, say Orders. Orders have line items that can be added arbitrarily. So a main view and nested partialviews.

Each part

2条回答
  •  爱一瞬间的悲伤
    2020-12-31 08:07

    I tried the exact same thing a while ago. No matter what I did, it wouldn't do the AJAX submit. So I think the answer is: yes, you can't put a submit button for an AJAX form inside a regular html form.

    But, why would you have partial submits merged with full submits? The easiest workaround to this imo would be to use JSON requests with jQuery.

    for instance, updating a quantity span text when you change a dropdownlist (id=Order):

    
    

    And the code in the "Orders" controller:

    public class OrdersController : Controller
    {
        public ActionResult UpdateQty(int id)
        {
            return Json(yourLibrary.getQuantities(id));
        }
    }
    

    This Link might help. Regards

    Edit:

    So.. the link no longer exists. But thanks to the internet wayback machine, we have this copy :)

提交回复
热议问题