我将 UserControl 动态加载到 MultiView 控件中的 View 中。尽管 UserControl 添加了一个事件处理程序,但该事件永远不会触发。
我在这里想念什么?谢谢!
包含 ASPX 页面:
protected override void OnPreRender(EventArgs e)
{
if (MultiView1.ActiveViewIndex == 2) //If the tab is selected, load control
{
Control Presenter = LoadControl("Presenter.ascx");
(MultiView1.ActiveViewIndex.Views[2].Controls.Add(Presenter);
}
base.OnPreRender(e);
}
演示者.ascx.cs
override protected void OnInit(EventArgs e)
{
Retry.Click += this.Retry_Click; //This is a .Net 2.0 project
base.OnInit(e);
}
protected void Retry_Click(object sender, EventArgs e)
{
//This never fires
}