Say I have a user control(SubmitButton) having a submit button that when a user clicked on, I want the control, which contains a SubmitButton instance, decide the behavior of submit button.
I have tried the following in the user control .cs file:
protected void nextPage_Click(object sender, EventArgs e) {
submitData();
Response.Redirect("completed.aspx");
}
protected abstract void submitData();
But I don’t know where the submitData method should be implemented.
It’s like a place holder for method.
Your control should expose event. For example SubmitClicked. Than in control that contains it You subscribe to that event and do whatever You choose to do. If you have event exposed You can attach to it as many event handlers as you like.
That’s what the asp:Button already does. It exposes Click event and in aspx page You just subscribe to that event and implement event handler in Your code behind file.