G
Guest
OK, I am trying to fire an event from a usercontrol that tells the page when
a checkbox was clicked.
Here is the control and when I try and wire up the page to catch the event,
my event is not shown. What am I doind wrong?
public delegate void CheckBoxEventHandler(object sender, System.EventArgs e);
public class WebUserControl1 : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.CheckBox CheckBox1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Response.Write("WebUserControl1 :: Page_Load <BR>");
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.CheckBox1.CheckedChanged += new
System.EventHandler(this.CheckBox1_CheckedChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public event CheckBoxEventHandler CheckedMe;
protected void OnCheckedMe(object sender, System.EventArgs e)
{
if(CheckedMe != null)
{
CheckedMe(this,e);
}
}
private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
{
Response.Write("WebUserControl1 :: Begin CheckBox1_Click <BR>");
OnCheckedMe(this,e);
Response.Write("WebUserControl1 :: End CheckBox1_Click <BR>");
}
a checkbox was clicked.
Here is the control and when I try and wire up the page to catch the event,
my event is not shown. What am I doind wrong?
public delegate void CheckBoxEventHandler(object sender, System.EventArgs e);
public class WebUserControl1 : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.CheckBox CheckBox1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Response.Write("WebUserControl1 :: Page_Load <BR>");
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.CheckBox1.CheckedChanged += new
System.EventHandler(this.CheckBox1_CheckedChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public event CheckBoxEventHandler CheckedMe;
protected void OnCheckedMe(object sender, System.EventArgs e)
{
if(CheckedMe != null)
{
CheckedMe(this,e);
}
}
private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
{
Response.Write("WebUserControl1 :: Begin CheckBox1_Click <BR>");
OnCheckedMe(this,e);
Response.Write("WebUserControl1 :: End CheckBox1_Click <BR>");
}