using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class 变量自增 : System.Web.UI.Page
{
private int a = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
Response.SetCookie(new HttpCookie("num", "0"));
//新建HttpCookie对象
this.Label1.Text = "0";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
int.TryParse(Request.Cookies["num"].Value, out a);
a++;
Response.SetCookie(new HttpCookie("num", a.ToString()));
this.Label1.Text = a.ToString();
}
}