I created a control where other developers can create an instance and use. There is a button click in the control. How do I allow developers to plug in their own code in a certain part of my control? I am not sure if or how exactly to use a delegate or event in this scenario. Can someone help in the below example:
public class MyControl : CompositeControl
{
...
void btnSubmit_Click(object sender, EventArgs e)
{
//DO SOMETHING
if (success)
{
//CALL DEVELOPER'S LOGIC
}
}
}
In the developers code, how can they pass in their logic when the button click of the control is successful?
protected override void CreateChildControls()
{
var ctlMyControl = new MyControl();
//ADD SuccessCode() TO ctlMyControl
//SO IT IS TRIGGERED ON SUCCESS
//MAYBE SOMETHING LIKE:
//ctlMyControl.SuccessEvent = SuccessCode()??
this.Control.Add(ctlMyControl);
}
protected void SuccessCode()
{
//DO SOMETHING
}
How to I update MyControl to allow this?