"AutoEventWireUp" is a very familiar word to ASP.Net native developers. They can find it in the @Page directive at the top of the page. It can have values "true" or "false". Many times I have heard the question in interviews like what is AutoEventWireUp? What if we set its value to true or false?Let's see what happens when it's values changes between true and false.Case: AutoEventWireUp="true"This is the default value for AutoEventWireUp attribute in C# and False for a VB.Net form so be specific while answering to somebody. You should know his/her context. When AutoEventWireup is true, all we need to do is follow the method naming convention of Page_EventToHandle. The ASP.NET runtime will automatically find and fire the method for the appropriate event.One more point for ASP.Net life cycle and events; see here for details. Now look at the syntax of let's say the Page_Load event. Here Load is the method that raises the event.protected void Page_Load(object sender, EventArgs e){}And protected void Page_Load(){}Both are valid because I think there must be two delegates defined to handle the event with these two different handlers. Now People say that from a performance point of view set the value of AutoEventWireUp to "false". Why?Reason is here:
public partial class _Default : Page{ public _Default() // ctor { Load += new EventHandler(Page_Load); PreInit += new EventHandler(Page_PreInit); } protected void Page_Load(object sender, EventArgs e) { // ... } protected void Page_PreInit(object sender, EventArgs e) { // ... }}Now you should have a look at this attribute when you are going to work on any ASP.Net WebApplication. Happy Coding....
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: