代码如下:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
TextBox box = new TextBox();
box.Text = "0";
box.ID = "a";
this.Panel1.Controls.Add(box);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox mytext = (TextBox)Panel1.FindControl("a");
if(mytext.Text.ToString().Trim() == "") //系统提示“未将对象引用设置到对象的实例。”
{
......
}
}