我想从另一个事件调用变量,例如
public void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
var ccc = lblTicketsA;
}
public void btnSubmit_Click(object sender, EventArgs e)
{
try
{
ccc.text = "test";
}
catch (Exception ex)
{
lblDisplay.Text = ex.Message;
}
}
谢谢
答案 0 :(得分:3)
使ccc
像这样的实例字段:
private SomeType ccc;
public void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
this.ccc = lblTicketsA;
}
public void btnSubmit_Click(object sender, EventArgs e)
{
try
{
this.ccc.text = "test"
}
catch (Exception ex)
{
lblDisplay.Text = ex.Message;
}
}