Ajax.ActionLink与Ajax.BeginForm使用场所的思考

Ajax.ActionLink使用在提交参数明确的情况下,如:

Ajax.ActionLink("加入购物车", "AddToCart", "Cart", new { GoodsId = 3, Amount = 10 }, ajaxOption, new { @class = "btn" })

这里的提交参数GoodsId及Amount值是可确定的。

Ajax.BeginForm使用在提交参数可能变化的场所,比如参数的值是用户选择的。如:

@using (Ajax.BeginForm("AddToCart", "Cart", ajaxOption))
            {

                 <input name="GoodsId" id="GoodsId" value="@Model.Goods.First().Id" type="hidden">

                 <input name="Amount" id="Amount" value="1" type="text">

                 <input id="addtocart" class="btn" type="submit" value="加入购物车" />

             }

原文地址:https://www.cnblogs.com/ahuang1118/p/4350260.html