using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { public static int number = 0; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { number = 0; } } protected void Button1_Click(object sender, EventArgs e) { ViewState["num"] = number; number = (int)ViewState["num"]; number++; this.Label1.Text = "你点击了" + number.ToString() + "次"; } }