G
Guest
1. I've got a default user control class with an event handler 'OnBubbleEvent':
public class DefaultUserControl : System.Web.UI.UserControl
{
public event EventHandler DoBubbling;
...
protected void OnBubbleEvent(EventArgs e)
{
DoBubbling(this, e);
}
...
}
2. Every user control class deriving from this default class may call that
event handler:
public class DerivedUserControl : DefaultUserControl
{
...
private void MyList_SelectedIndexChanged(object sender, System.EventArgs e)
{
OnBubbleEvent(e);
}
...
}
3. In my main page all user controls derived from the default class are
loaded dynamically:
public class MainPage : System.Web.UI.Page
{
...
private void FetchBubble(object sender, EventArgs e)
{
DefaultUserControl myControl;
if (this.Session[nameOfControl] == null)
{
myControl = (DefaultUserControl) this.LoadControl(nameOfControl);
this.Session[nameOfControl] = myControl;
myControl.ID = myControl.ToString();
}
else
{
myControl = (DefaultUserControl) this.Session[nameOfControl];
}
myControl.DoBubbling += new EventHandler(this.FetchBubble);
this.MyPanel.Controls.Add(myControl);
...
private void FetchBubble(object sender, EventArgs e)
{
this.ActivateControl();
}
}
public class DefaultUserControl : System.Web.UI.UserControl
{
public event EventHandler DoBubbling;
...
protected void OnBubbleEvent(EventArgs e)
{
DoBubbling(this, e);
}
...
}
2. Every user control class deriving from this default class may call that
event handler:
public class DerivedUserControl : DefaultUserControl
{
...
private void MyList_SelectedIndexChanged(object sender, System.EventArgs e)
{
OnBubbleEvent(e);
}
...
}
3. In my main page all user controls derived from the default class are
loaded dynamically:
public class MainPage : System.Web.UI.Page
{
...
private void FetchBubble(object sender, EventArgs e)
{
DefaultUserControl myControl;
if (this.Session[nameOfControl] == null)
{
myControl = (DefaultUserControl) this.LoadControl(nameOfControl);
this.Session[nameOfControl] = myControl;
myControl.ID = myControl.ToString();
}
else
{
myControl = (DefaultUserControl) this.Session[nameOfControl];
}
myControl.DoBubbling += new EventHandler(this.FetchBubble);
this.MyPanel.Controls.Add(myControl);
...
private void FetchBubble(object sender, EventArgs e)
{
this.ActivateControl();
}
}