private TextBox txt;
protected void Page_Load(object sender, EventArgs e)
{
this.txt = new TextBox { Text = "", ID = "SomeID" };
this.Form.Controls.Add(this.txt);
Button btn = new Button { Text = "Submit", ID = "btnsubmit" };
btn.Click += btn_Click;
this.Form.Controls.Add(btn);
}
protected void btn_Click(object sender, EventArgs e)
{
string data = this.txt.Text;
}