新手求帮助 同一页面中怎样调用上一单击事件的运算结果?
同一页面中怎样调用上一单击事件的运算结果?如: protected void operator1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "" || TextBox2.Text == "" )
{
return;
}
Button OperaterButton = (Button)sender;
float Number1, Number2,Result1 =0;
Number1 = float.Parse(TextBox1.Text);
Number2 = float.Parse(TextBox2.Text);
switch (OperaterButton.ID)
{
case "Button1":
Result1 = Number1 + Number2;
break;
}
TextBox12.Text = Result1.ToString();
}
protected void operator2_Click(object sender, EventArgs e)
{
if (TextBox13.Text == "" || TextBox14.Text == "")
{
return;
}
Button OperaterButton = (Button)sender;
float Number13, Number14, Result2 = 0;
Number13 = float.Parse(TextBox13.Text);
Number14 = float.Parse(TextBox14.Text);
switch (OperaterButton.ID)
{
case "Button3":
Result2 = Result1*100 / (Number13 * Number14);
break;
}
TextBox15.Text = Result2.ToString();
}
operator2_Click事件中的Result1不存在,怎样才能调用operator1_Click事件中的Result1?
求帮忙,非常感谢!