Problems with event bubbling

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();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Problems with event bubbling 0
Dynamic Button with Event 6
event 3
Get Event Argument Value 1
Getting value of instances of variable. 1
Event question 4
Problem with event handler 0
Paging using repeater control 0

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top