473,395 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Autoeventwireup in asp.net

366 256MB
hi friends

can anybody explain difference between AutoEventWireup="false" and AutoEventWireup="true" in asp.net .what actually is the use of that event .




Thanks&Regards
nmsreddi
Aug 26 '06 #1
1 4957
Check out the Code
When we create a new ASP.NET Web Application in Visual Studio .NET, as mentioned earlier, by default, the value of the AutoEventWireup attribute is set to false in the .aspx page and event handlers are automatically created. We can find this in the InitializeComponent method:

this.Load += new System.EventHandler(this.Page_Load);
The best way to see the working of this attribute would be:

Declare a string variable msg as public in WebForm1.aspx.cs.
In the HTML section of WebForm1.aspx, enter the following code in the <Head> section:
<% Response.Write(msg); %>
In the Page_Load, you could enter a value for the variable msg declared.

msg= "We are in Page_Load()";
On running the application, you will get the message We are in Page_Load() [hereafter referred to as message]. Note: this is in the default case where the attribute is set to false.

Now try commenting the event handler code for the Page_Load in the aspx.cs file; and set the AutoEventWireup attribute to false in the .aspx page. On running the application this time, you will not get the message.

Now with the event handler code for the Page_Load in the aspx.cs file still commented; set the AutoEventWireup attribute to true in the .aspx page. On running the application this time, you will get the message.

Reason: In the case where AutoEventWireup attribute is set to false (by default), event handlers are automatically required for Page_Load or Page_Init. However, when we set the value of the AutoEventWireup attribute to true, the ASP.NET runtime does not require events to specify event handlers like Page_Load or Page_Init.

A thing to be kept in mind is that the AutoEventWireup attribute of the Page directive is set to true by default for the machine (check out the value of this attribute in the machine.config) but set to false by default for a .aspx page). So if it is missing, since by default it is true (i.e., at the machine level), the page framework calls page events automatically, specifically the Page_Init and Page_Load methods. In that case, no explicit Handles clause or delegate is needed.

Performance Issues
Mar 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Guy Lafleur | last post by:
I have a user control that builds a treeview dynamically in the Page_Load event. Also, I have the AutoEventWireup property set to true (i.e., <%@ Control AutoEventWireup="true" %>). Then, when I...
1
by: Quentin Huo | last post by:
Hi: This morning I found something wrong in my asp.net application: some pages and user controls didn't work well. it seems their Page_load method didnot work. For example if add a statement in...
1
by: prem | last post by:
Hi , Any one please give me the Usage with example for AutoEventWireUp PageDirective. Regards, Prem.
1
by: thomson | last post by:
Hi All, i have written a Web application program, in the page load i have given Response.write=("true") if in the page attribute, the default is AutoEventWireup="false", when i run the program,...
0
by: -Karl | last post by:
Ok.. I am totally stumped on this one. My site was workign great for awhile until I needed to have a Page_load event added to it. I added it and saw that it wasn't working. After ripping apart...
7
by: Danny Tuppeny | last post by:
Hi all, Looks like autoEventWireup defaults to true in 2.0. Kinda silly if you ask me, since the MS site says there's a performance penalty, and I can't imagine it's something used very often! ...
5
by: Juan T. Llibre | last post by:
OK, guys, usually I answer questions instead of asking them, but this thing has me scratching my head. Why is the default for AutoEventWireup different for C# and VB.NET ? In VS 2005, if I...
28
by: Tim_Mac | last post by:
hi, i'm new to .net 2.0, and am just starting to get to grips with the gridview. my page has autoEventWireUp set to true, which i gather is supposed to figure out which handlers to invoke when...
5
by: Carlo Marchesoni | last post by:
I read that autoeventwireup="false" doesn't cause Page_Load to fire automatically and trying it out with a simple page this can be confirmed easily. However, I have a page with...
0
by: ABCL | last post by:
Hi All I have UserControl with "AutoEventWireUp="true" Property, and I have drop this User Control on the Master Page MasterPage has: <%@ Master Language="C#" AutoEventWireup="true" ...../> ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.