📄 productinfo.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 eshop
{
/// <summary>
/// ProductInfo 的摘要说明。
/// </summary>
public class ProductInfo : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblSearchResults;
protected System.Web.UI.WebControls.Label lblProductName;
protected System.Web.UI.WebControls.Label lblPrice;
protected System.Web.UI.WebControls.Label lblIntro;
protected System.Web.UI.WebControls.Label lblQty;
protected System.Web.UI.WebControls.Label lblClickCount;
private void Page_Load(object sender, System.EventArgs e)
{
//页面第一次加载时
if (!Page.IsPostBack)
{
ShowProductInfo();
}
}
void ShowProductInfo()
{
//获取Get方式传递的ProductId参数的值
int productId = int.Parse(Request["ProductId"]);
//获取某个商品的详细信息
BLL.ProductDetails pro = BLL.Product.GetProductInfo(productId);
//商品是否存在
if (pro == null)
{
lblSearchResults.Text = "没有这个商品";
}
else
{
//显示商品详细信息
lblProductName.Text = pro.productName;
lblPrice.Text = pro.productPrice.ToString();
lblIntro.Text = pro.intro;
lblClickCount.Text = pro.clickCount.ToString();
}
}
#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 + -