?? pubcart.aspx.cs
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace shop
{
/// <summary>
/// pubCart 的摘要說明。
/// </summary>
public class pubCart : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblNotice;
#region 自定義私有變量
private string sProductId;
#endregion
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
//判斷用戶是否登錄
if((object.Equals(Session["UserName"],null)) || (object.Equals(Session["UserId"],null)))
lblNotice.Text = "您還沒有登錄,請先登錄!";
else
{
if(!object.Equals(Request.QueryString["ProductId"],null))
{//獲得傳入商品的id號
sProductId = Request.QueryString["ProductId"];
if(object.Equals(Session["ProductInCart"],null))
Session["ProductInCart"] = new Hashtable();
if(!((Hashtable)Session["ProductInCart"]).Contains(sProductId))
((Hashtable)Session["ProductInCart"]).Add(sProductId,1);
//跳轉到購物車頁
Response.Redirect("shoppingCart.aspx");
}
}
}
#region Web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -