Always create your dynamic control in
Page_Init
event (Read
this[
^] for a detailed information).
Change your CS. Try this:
protected void Page_Init(object sender, EventArgs e)
{
Label lbl = new Label();
lbl.ID = "Lbl1";
lbl.Text = "Arun";
lbl.Visible = false;
Panel1.Controls.Add(lbl);
}
protected void BtnAdd_Click(object sender, EventArgs e)
{
Label Lbl = (Label)Panel1.FindControl(lblName);
if(lbl != null)
lbl.Visible = true;
}
protected void BtnTake_Click(object sender, EventArgs e)
{
string lblName = "Lbl1";
Label Lbl = (Label)Panel1.FindControl(Lbl1);
TextBox1.Text = Lbl.Text;
}
--Amit