public partial class WebForm1 : System.Web.UI.Page { public int i; public static int j; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { i = 9; j = 9; } } protected void Button1_Click(object sender, EventArgs e) { Response.Write(i.ToString()+" "+j.ToString()); } }
点击按钮后运行结果
0 9