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

How To Pass Back Your Own Object From An Event Call

DebriefDialogResult.cs (New class that inherits from EventArgs

namespace com.aep.ehap.ui
{
    /// <summary>
    /// JHA result from Debrief Dialog
    /// </summary>
    public class DebriefDDialogResult : EventArgs
    {

        /// <summary>
        /// Gets or sets the jha.
        /// </summary>
        /// The jha.
        public JobHazardAnalysis JHA { get; set; }
    }
}

DebriefFeedback.ascx.cs (Code Behind to DebriefFeedback.ascx) which sits in ViewJHA.aspx

 public partial class DebriefFeedback : System.Web.UI.UserControl
    {
        /// <summary>
        /// Occurs when [debrief feedback added].
        /// </summary>
        public event DebriefFeedbackAddedHandler DebriefFeedbackAdded;

        /// <summary>
        /// Delegate for DebriefFeedbackAddedHandler
        /// </summary>
        public delegate void DebriefFeedbackAddedHandler(object sender, DebriefDDialogResult e);

		
		/// <summary>
        /// Handles the Click event of the wibSendFeedback control.
        /// </summary>
        /// The source of the event.
        /// The  instance containing the event data.
		 protected void wibShareYourComment_Click(object sender, Infragistics.WebUI.WebDataInput.ButtonEventArgs e)
        {
		...
		..
		.
		
		  DebriefFeedbackAddedHandler handler = DebriefFeedbackAdded;
          if (handler != null)
              handler(this, new DebriefDDialogResult() { JHA = this.JobHazardAnalysis });
		
		}

ViewJHA.aspx.cs


protected void Page_Load(object sender, EventArgs e)
        {

// Wire up event for DebriefFeedbackAdded            
            this.ctrlDebriefFeedback.DebriefFeedbackAdded += new DebriefFeedback.DebriefFeedbackAddedHandler(ctrlDebriefFeedback_DebriefFeedbackAdded);

}


        void ctrlDebriefFeedback_DebriefFeedbackAdded(object sender, DebriefDDialogResult e)
        {
            // Wire up Review JHA Control from altered JHA in Debrief Comment control
            if (e.JHA != null)
            {

                ctrlReviewJHACtrl.JobHazardAnalysis = e.JHA;
                ctrlReviewJHACtrl.ReviewContext = false;
                ctrlReviewJHACtrl.BindControl();
              
            }
        }