我写了这样一个控件
public class ImgSpan : WebControl, INamingContainer
{
public string Path;
private EventHandler ButtonClick;
protected override void CreateChildControls()
{
Controls.Clear();
Button btn = new Button();
Label lbl = new Label();
lbl.Text = Path;
btn.Text = "删除";
btn.CommandArgument = Path;
btn.Click += ButtonClick;
Controls.Add(lbl);
Controls.Add(btn);
ClearChildViewState();
}
public ImgSpan(EventHandler buttonClick, string path)
{
ButtonClick = buttonClick;
Path = path;
}
}
//调用
this.Controls.Add(new ImgSpan(btnDelete_Click, info.SavePath));
为什么点击ImgSpan的按钮时,无什么无法触发 btnDelete_Click 事件?