What is AutoEventWireup ?
The ASP.NET page framework supports an automatic way to associate page events and methods. When a Page is requested, it raises various events which are considered to be part of it's lifecycle. AutoEventWireup is an attribute of the @ Page directive. The AutoEventWireup attribute may have a value of true or false.
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 Examples of these built-in events would be Page_Init and Page_Load.
The value of AutoEventWireup = false means that your Page_Load event will not be automatically hooked to the page's Load event and so on for PreRender and the other page lifecycle events. It means in the constructor of your code-behind base class for the Page, you will have to manually do.
You can specify a default value of the AutoEventWireup attribute in several places:
To change the value of the AutoEventWireup attribute in the individual ASP.NET Web Form, add the AutoEventWireup attribute to the @ Page directive, as follows:
In Visual Studio
When you use Microsoft Visual Studio .NET, the value of the AutoEventWireup attribute is set to false and the designer automatically generates event handlers. 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. This can result in the same event code being called twice when the page runs. As a consequence, you should always leave AutoEventWireup set to false when working in Visual Studio.
The disadvantage of the AutoEventWireup attribute is that it requires that the page event handlers have specific, predictable names. This limits your flexibility in how you name your event handlers. Therefore, in Visual Studio, the AutoEventWireup attribute is set to false by default and the designer generates explicit code to bind page events to methods.
- What is IIS - Internet Information Server
- What is Virtual Directory
- What is HttpHandler
- Page Directives in Asp.Net
- What is a postback
- What is IsPostBack
- What is global.asax
- Difference between Machine.config and web.config
- Difference between HTML control and Web Server control
- What is Query String
- Difference between Authentication and Authorization
- How to secure Connection Strings
- What is ASP.Net tracing
- Passing values between Asp.Net pages
- Differentiate between client side validation and server side validation
- How to Get host domain from URL
- Adding a Favicon To Your Website