首页 新闻 赞助 找找看

为什么复合控件的按钮的点击事件会失效?

0
悬赏园豆:15 [待解决问题]

我写了这样一个控件

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 事件?

Ten_cnblogs的主页 Ten_cnblogs | 初学一级 | 园豆:21
提问于:2015-02-13 15:17
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册