Cargo dinámicamente un UserControl en una vista que está en un control MultiView. Aunque UserControl agrega un controlador de eventos, el evento nunca se dispara.Controlador de eventos UserControl que no se activa
¿Qué me falta aquí? Gracias!
Conteniendo página 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);
}
Presenter.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
}
Eso fue todo. ¡Gracias! Tuve que eliminar la declaración If también porque en OnPreInit, MultiView1.ActiveViewIndex no está configurado. –
eres bienvenido. –
¡Muchas gracias! –