0
我有一个可视的Web部件,用于下面的代码的SharePoint,但点击处理程序的代码永远不会触发。这有什么错我的代码?:点击事件不会触发
protected Button btApply;
protected void Page_Load(object sender, EventArgs e)
{
... some code ...
btApply = new Button();
btApply.Text = "Apply";
btApply.CssClass += "InputControl";
btApply.Click += new EventHandler(btApplyClick);
this.Controls.Add(btApply);
... some code ...
}
protected void btApplyClick(object sender, EventArgs e)
{
... some code ...
}
控件的初始化必须处于preinit事件中,以便页面生命周期能够优先处理事件。 – JSJ