I’ve got a user control that has an event that I can subscribe to. This works (ignore syntax):
protected void Page_Load(object sender, EventArgs e) { ucControl.Event += new Event(ucControl_Event); }
but if I removed this line and put the event wire up in my aspx page, it doesn’t work. Ex:
<uc1:ucControl id='uc_Control1' runat='server' Event='ucControl_Event' />
I get compilation error when I try it without the ucControl.Event += method.
The error is that the page does not contain a definition for ‘ucControl_Event’ when its obvious that it does.
How do I match my code behind event with the aspx file?
What’s the visibility of your event handler? If it’s private then approach 1 works, approach 2 doesn’t. If it’s protected or public, both work.