On Page_Init, if is post back, I check if a button called Button1 was clicked, if so I add a LiteralControl to a Panel called Panel1:
Panel1.Controls.Add(new LiteralControl("Enter Code:<input type=\"text\" name=\"txtCode\"></td>"));
As you can see, it is just the text "Enter Code:" followed by a TextBox called txtCode.
I have a second button (Button2) that, when clicked, I would like to retrieve the text entered in txtCode:
protected void Button2_Click(object sender, EventArgs e)
{
foreach (Control c in Panel1.Controls)
{
if (c is LiteralControl) ...
}
}
I'm not sure how to do this... How can I get the text entered in txtCode?