AutoEventWireup="false" and Page_Load and Overrides

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.

thanks!
LVL 2
Starr DuskkASP.NET VB.NET DeveloperAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Sachintana DissanayakeConnect With a Mentor Senior Web DeveloperCommented:
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.
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
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?
0
 
Sachintana DissanayakeSenior Web DeveloperCommented:
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.
0
All Courses

From novice to tech pro — start learning today.