I think by auto wire-up, they mean that buttons will automatically map to buttonName_OnClick. This isn't the same as explicitly declaring OnClick="buttonName_Click".
I also believe that this statement: Also note that the default value for aspx pages in C# is true & for VB.NET is false. is in error as in the link that Ulfat posted, it says:
AutoEventWireup is false when we create a new web application and event handlers are automatically created. We can find this in the Initialize Component method...
The best way to see the working of this attribute would be:
Declare a stringvariable 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.
brianjlowry
Member
59 Points
46 Posts
Re: What is AutoEventWireup?
Jan 18, 2008 03:19 AM|LINK
I think by auto wire-up, they mean that buttons will automatically map to buttonName_OnClick. This isn't the same as explicitly declaring OnClick="buttonName_Click".
moredotnet
Contributor
4685 Points
887 Posts
Re: What is AutoEventWireup?
Jan 18, 2008 04:01 AM|LINK
Check this out... http://forums.asp.net/p/932513/1096656.aspx
Also note that the default value for aspx pages in C# is true & for VB.NET is false.
HTH
BOOK: .NET INTERVIEW CRACKERJACK
WEBSITE: ASP.NET, C#, AJAX, SQL, Design Patterns
ulfat
Member
8 Points
7 Posts
Re: What is AutoEventWireup?
Mar 17, 2008 11:53 AM|LINK
Autoeventwireup has nothing to do with the button hanlders.It works only for Page Events.
for more details see the article by using link below.
http://blogs.ittoolbox.com/c/coding/archives/autoeventwireup-attribute-9312
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: What is AutoEventWireup?
Mar 17, 2008 12:01 PM|LINK
I also believe that this statement: Also note that the default value for aspx pages in C# is true & for VB.NET is false. is in error as in the link that Ulfat posted, it says:
AutoEventWireup is false when we create a new web application and event handlers are automatically created. We can find this in the Initialize Component method...
NC...
dotnetwithrp
Member
12 Points
1 Post
Re: What is AutoEventWireup?
Jul 06, 2008 06:51 AM|LINK
-
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.