Easily Raise Events From Web Control to Parent Page

In Web Control

public event System.EventHandler TabClicked;

Raise it whenever you want like this:

// Raise the tabclicked event.
if(this.TabClicked != null)
this.TabClicked(this, new EventArgs());

Then in your containing class/page you wire up the event like so:

this.MyControl1.TabClicked +=new EventHandler(MyControl_TabClicked);

Where MyControl_TabClicked is a method with a signature that looks like this:

private void MyControl_TabClicked(object sender, EventArgs e){}

Source

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s