我在c#代码中创建了一个文件上传控件和一个上传按钮,如下所示:控件正在创建并显示在UI-aspx中
TableCell uploadCell = new TableCell();
uploadCell.ColumnSpan = 4;
tRow.Cells.Add(uploadCell);
FileUpload fu = new FileUpload();
fu.ID = "fu_" + BU + "_" + artifact.LookupValue + artifact.LookupId;
fu.AllowMultiple = false;
Button btnUpload = new Button();
btnUpload.ID = "btnUpload_" + BU + "_" + artifact.LookupValue + artifact.LookupId;
btnUpload.Text = "Upload";
btnUpload.Click += new EventHandler(this.btnUpload_Click);
PostBackTrigger trigger = new PostBackTrigger();
trigger.ControlID = btnUpload.ID;
uploadCell.Controls.Add(fu);
uploadCell.Controls.Add(btnUpload);
Up1.Triggers.Add(trigger);
private void btnUpload_Click(object sender, EventArgs e)
{
}
当我点击上传按钮时,点击事件不会被触发。我在btnUpload_Click
附加了一个调试,但是没有打到。
如何触发点击事件以动态添加控件?