ASP值view State

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() + "次";
       
    }
    
}

  

posted @ 2016-11-02 11:19  尘梦  阅读(221)  评论(0编辑  收藏  举报