Search code examples
.netasp.netweb-controls

When creating a web control should you override OnLoad or implement Page_Load


When you create a new web user control in visual studio it by default adds the Page_Load event. What is the advantage to using this rather than overriding the base OnLoad event on the control? Is it just that the Page_Load event fires before OnLoad?


Solution

  • The OnLoad method should be the place where the Load event is raised. I personally always try to handle the event unless I need to do extra processing around raising the event.

    I recommend handling the event itself under normal circumstances.