【Asp.Net-- 杂七杂八】的代码
2020-12-13 14:57
标签:des style class blog code java $.ajax 【Asp.Net-- 杂七杂八】的代码,搜素材,soscw.com 【Asp.Net-- 杂七杂八】的代码 标签:des style class blog code java 原文地址:http://www.cnblogs.com/easy5weikai/p/3795530.html
Request.Url.PathAndQuery
public RedirectResult AddToCart(Cart cart, int productId, string returnUrl)
{
Product product = this.productRepository.Products
.FirstOrDefault(p => p.ProductID == productId);
if (null != productId)
{
cart.AddItem(product, 1);
}
returnUrl = this.Request["returnUrl"];
//return RedirectToAction("Index", new { returnUrl });
return Redirect(returnUrl);
}
@model Easy5.ASPMVC.SportsStore.Domain.Entities.Product
@Model.Name
@Model.Description
@using(Html.BeginForm("AddToCart", "Cart"))
{
/* 1.创建一个隐藏的字段ProductID
*/
@Html.HiddenFor(x=>x.ProductID)
/* 2.实参:"returnUrl" 必须与对应的参数的参数名名一样
*/
@Html.Hidden("returnUrl", Request.Url.PathAndQuery)/*返回本页面的请求地址*/
"submit" value="+ 加入购物车"/>
}
@Model.Price.ToString("c")
@Url.Action
"text-align: center;">
"@Url.Content("~/Images/Update.png")" alt="更新" title="更新" class="UpdateShoppingCartItemButton" id="@string.Format("update_{0}", item.ID)" />
"text-align: center;">
"@Url.Content("~/Images/Delete.png")" alt="删除" title="删除" class="DeleteShoppingCartItemButton" id="@string.Format("delete_{0}", item.ID)" />
@section scripts{
}
上一篇:插入排序
下一篇:C++11并发编程入门