We help IT Professionals succeed at work.

AutoEventWireup="false" and Page_Load and Overrides

Starr Duskk
Starr Duskk asked
Medium Priority
Last Modified: 2008-03-17
In VB, creating a new page defaults AutoEventWireup="false" I've been using Handles Me.Load on the events.

Someone said I should use Overrides on the OnLoad and OnInit instead. Why?

What are they talking about? Why do that? What's the benefit? What are the settings for the AutoEventWireup if I do it that way? Leave out the Handles?

Please explain why or why not to use Handles versus Overrides.

Watch Question

Senior Web Developer
AutoEventWireup="false", you can customize the Event name and it's required to use the event handler define an event.
    Private Sub Page_Load_Event(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Write("AutoEventWireup is false")
    End Sub

With AutoEventWireup="true" , you can override the existing event that fires from the Page_Load event.

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Response.Write("AutoEventWireup is true")
    End Sub

In VB, AutoEventWireup set to false by default where in C# it;s set to true.
Starr DuskkASP.NET VB.NET Developer


So to override an existing event, instead of customizing an event that handles an event, you have to have AutoEventWireup="true".

Which the documentation says to avoid this if performance is an issue. So considering on all websites performance is likely an issue, it is better to use false and Handles, rather than overriding? Because use "true" automatically hits all events, needed or not, right?
Sachintana DissanayakeSenior Web Developer

Yes, overriding reduces the performance, that's a base concept.
Event handling will fires as an event, but in a override it has to find all the overrides when executing Page_Load internally.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.