- 加入购物车
@using (Html.BeginForm("AddToCart", "Cart"))
{
<div class="pull-right">
@Html.HiddenFor(x=>x.Id)
@Html.Hidden("returnUrl",Request.Url.PathAndQuery)
<input type="submit" class="btn btn-success" value="加入购物车" />
</div>
}
等效于
<form action="/Cart/AddToCart" method="post">
<div class="pull-right">
<input data-val="true" data-val-number="字段 Id 必须是一个数字。" data-val-required="Id 字段是必需的。" id="Id" name="Id" type="hidden" value="1">
<input id="returnUrl" name="returnUrl" type="hidden" value="/?categoryId=1">
<input type="submit" class="btn btn-success" value="加入购物车">
</div>
</form>