how I can call a variable (private Label ccc;) in another event:
private Label ccc;
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label Label1 = FindControlRecursive(Page, DropDownList1.SelectedValue) as Label;
if (Label1 != null)
this.ccc = lblCont;
this.ccc.Text = Label1.Text;
}
public void btnSubmit_Click(object sender, EventArgs e)
{
try
{
this.ccc.Text = lblCont.Text;
int bbb = Convert.ToInt32(lblCont.Text) - Convert.ToInt32(tbEnter.Text);
if (bbb >= 0)
{
lblCont.Text = Convert.ToString(bbb);
}
else
{
ErrorDisplay.Text = "There are not enough tickets";
}
}
catch (Exception ex)
{
ErrorDisplay.Text = ex.Message;
}
}
I can not call this.ccc.Text = lblCont.Text; in "public void btnSubmit_Click"
It does (Object reference not set to an instance of an object.)
Thakns!!