This is more than a naming convention because events in user controls automatically get the prefix “On” in declarative syntax.
For example, I have a UserControl that declares a ProjectSelected event. To add a handler declaratively, I set the OnProjectSelected attribute.
UserControl:
public event EventHandler<ProjectSelectedEventArgs> ProjectSelected;
Adding a handler declaratively:
<user:ProjectList id="uxProjectList" runat="server" OnProjectSelected="uxProjectList_ProjectSelected" />
Adding a handler to the code behind:
uxProjectList.ProjectSelected += uxProjectList_ProjectSelected;
This drove me crazy twice when I couldn't understand why the event was not available declaratively, and again when I called the event “OnProjectSelected” and the attribute became “OnOnProjectSelected”.
Jamie idea
source share