The framework has a way of wiring this through some convention.
You normally declare a public delegate and define a public event in your user control using that delegate. In the control markup use
OnEventName="PageMethod"
. Where
EventName is the name of the event defined in the usercontrol and
PageMethod is the method in the aspx page. Trigger the event from user control code-behind.
Say delegate is as follows:
public delegate void ClickHandler();
Event definition inside user control class is as follows:
public event ClickHandler Clicked;
Write code which fires the event. In this case button click:
public void btnSubmit_Click(object s, EventArgs e)
{
if(Clicked != null) Clicked();
}
Finally the markup:
<cc1:uc1 id="uc1" runat="server" önClicked="UcClicked"></cc1:uc1>
Make sure there exists a page a method on the page; it should not be private.