Views/Default/ProductList.cshtml
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
@using PagedList;
@using PagedList.Mvc;
@model IEnumerable<MvcShopping.Models.Product>
@{
var ajaxOption = new AjaxOptions() { OnSuccess="AddCartSuccess",OnFailure="AddCartFail",HttpMethod="Post", Confirm = "确定要添加到购物车?" };
var data = Model as IPagedList<MvcShopping.Models.Product>;
}
<link href="~/Content/PagedList.css" rel="stylesheet" />
@section scripts{
@Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"> </script>
<script>
function AddCartSuccess() {
alert("添加成功");
}
function AddCartFail(xhr)
{
alert("添加失败"+xhr);
}
</script>
}
<h2>@Html.DisplayNameFor(model=>model.ToList()[0])</h2>
<h3>您正在浏览【@Model.First().ProductCategory.Name】的商品</h3>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th>
@Html.DisplayNameFor(model => model.Price)
</th>
<th>
添加购物车
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@*@Html.DisplayFor(modelItem => item.Name)*@
@Html.ActionLink(item.Name,"ProductDetail",new { id=item.Id})
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.Price)
</td>
<td>
@Ajax.ActionLink("添加购物车", "AddToCart","Cart",new { ProductId =item.Id}, ajaxOption)
</td>
后面还有 5 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。