fr33kyd33ky
MIS
C#/asp.net
I have a TextBox that is created in a sub. It is created fine and with the correct id, but I'm unable to find it on submit. I get an error object reference not set to object. My code is below. Can someone please tell me what I'm doing wrong?
I have a TextBox that is created in a sub. It is created fine and with the correct id, but I'm unable to find it on submit. I get an error object reference not set to object. My code is below. Can someone please tell me what I'm doing wrong?
Code:
protected void MakeTB()
{
System.Web.UI.WebControls.TextBox tb;
tb = new System.Web.UI.WebControls.TextBox();
tb.ID = "File1"
TableCellFiles11.Controls.Add(tb);
}
protected void Submit(object sender, EventArgs e)
{
TableCell tc = TableCellFiles11;
tc.ID = TableCellFiles11.ID;
System.Web.UI.WebControls.TextBox tb;
tb = new System.Web.UI.WebControls.TextBox();
tb = tc.FindControl("File1") as System.Web.UI.WebControls.TextBox;
Response.Write(tb.Text);
}