I don't understand what the AutoEventWireUp
page property is responsible for.
I've read through this article, but even that I don't understand.
AutoEventWireup is an attribute in Page directive. AutoEventWireup is a Boolean attribute that indicates whether the ASP.NET pages events are auto-wired. AutoEventWireup will have a value true or false. By default it is true.
If you do set AutoEventWireup to true, Visual Studio will generate code to bind the events and the page framework will automatically call events based on their names.
When a Page is requested, it raises various events which are considered to be part of it's lifecycle. I keep the visual representation created by Peter Bromberg handy with me.
The AutoEventWireUp
property when True, automatically wires up some of these built-in events in the Page life cycle to their handlers. This means that you do not need to explicitly attach these events (using the Handles keyword, for instance, in VB).
Examples of these built-in events would be Page_Init
and Page_Load
.
If you set AutoEventWireUp
to True and provide explicit wiring up of the EventHandlers, you will find them being executed twice! This is one reason why Visual Studio keeps this attribute set to false
by default.
Edit: (after Chester89's comment)
It is useful to note that the default value of the AutoEventWireUp
attribute of the Page is true
, while the default value of the AutoEventWireUp
property of the Page class is false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With