I am able to create a web control programmatically and display on the form. In the click event of the button then I am trying to capture the value entered in the above created textbox in another click of button but I am unable to obtain the reference of the control that has been created dynamically.
Can anyone help me please?
protected System.Web.UI.WebControls.Panel myPanel;
private void btnMake_Click(object sender, System.EventArgs e)
{
TextBox txtBox = new TextBox();
myPanel.Controls.Add(txtBox);
}
private void btnGotValues_Click(object sender, System.EventArgs e)
{
TextBox myTextBox =(TextBox)myPanel.Controls[1];
lblMessage.Text = myTextBox.Text;
lblMessage.Visible = true;
}
Can anyone help me please?
protected System.Web.UI.WebControls.Panel myPanel;
private void btnMake_Click(object sender, System.EventArgs e)
{
TextBox txtBox = new TextBox();
myPanel.Controls.Add(txtBox);
}
private void btnGotValues_Click(object sender, System.EventArgs e)
{
TextBox myTextBox =(TextBox)myPanel.Controls[1];
lblMessage.Text = myTextBox.Text;
lblMessage.Visible = true;
}