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="加入购物车" />

             }

 

posted @ 2015-03-19 14:03  虚空境界  Views(300)  Comments(0Edit  收藏  举报