c# 窗体上有一个textbox控件,一个button控件。要求每当用户单击按钮时,文本框会自动反映单机的次数
3个回答
展开全部
winform还是纯肆扒asp.net
对于asp.net
protected void Button1_Click(object sender, EventArgs e)
{
int hits;
if (ViewState["hits"] == null)
{
hits = 0;
}
else
{
hits = (int)ViewState["hits"];
}
hits++;
ViewState["做昌hits"] = hits;
this.TextBox1.Text = hits.ToString();
}
对于winform
public int i;
private void button1_Click(object sender, EventArgs e)
{
i++;
this.textBox1.Text = "单击了"+i.ToString()+"次";
}
private void Form1_Load(object sender, EventArgs e)
{
i = 0;
}
以上代码vs 2005 vs 2008均调试通过雹喊
对于asp.net
protected void Button1_Click(object sender, EventArgs e)
{
int hits;
if (ViewState["hits"] == null)
{
hits = 0;
}
else
{
hits = (int)ViewState["hits"];
}
hits++;
ViewState["做昌hits"] = hits;
this.TextBox1.Text = hits.ToString();
}
对于winform
public int i;
private void button1_Click(object sender, EventArgs e)
{
i++;
this.textBox1.Text = "单击了"+i.ToString()+"次";
}
private void Form1_Load(object sender, EventArgs e)
{
i = 0;
}
以上代码vs 2005 vs 2008均调试通过雹喊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询