When I created zipsearch.aspx file, the following
code was generated:
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="zipsearch.aspx.vb" Inherits="ZipcodeDB.zipsearch"%>
What is AutoEventWireup? - what is the effect is set to true or false?
the ASP.NET page framework also supports an automatic way to associate page events and methods. If the
AutoEventWireup attribute of the Page directive is set to
true (or if it is missing, since by default it is true), 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.
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.
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.
If you know VB then remeber what happens if you double click on a button in "desing time" in the code an event procedure
Button_click( ) would come up for you to enter the code.
This is a classic feature of Auto event wireup - and in VB you had to live with it.
But in .NET you can name the event handling function whatever you want and tie up the event with the corresponding handling function.
So if you have a button you could call the MyNewButton_click( ) function. But for this to be possible the "Auto Event Wire-up" property must be set to false at the page level.
Hope this helps [:)]
Thanks and Regards
Niruma
The difference between try and triumph is just a little umph!
I'm very new to ASP.NET, so correct me if I am wrong, but I don't think it matters whether AutoEventWireup is true of false, you can still name your event handling functions whatever you want.
Eg. in your .aspx file you can have something like:
Note that the handling function has to be protected, not private, as it is referenced in the markup. However, for AutoEventWireup to work, you still have to use the Page_Load and Page_Init names for those functions.
I came across this post googling "AutoEventWireup" - it is the first result on Google, so although this post may be long dead in the context of our community, that is far from being true in the wider sense. The post was useful to me, but it also contained some
misinformation. I made the call to fix it, granted, at a cost to this community, but hopefully for a greater benefit to all. My sincerest apologies to anyone who didn't get an answer they needed because of this.
karma12
Member
15 Points
3 Posts
What is AutoEventWireup?
Oct 28, 2005 06:04 PM|LINK
code was generated:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="zipsearch.aspx.vb" Inherits="ZipcodeDB.zipsearch"%>
What is AutoEventWireup? - what is the effect is set to true or false?
Thanks
XIII
All-Star
182674 Points
23445 Posts
ASPInsiders
Moderator
MVP
Re: What is AutoEventWireup?
Oct 28, 2005 06:31 PM|LINK
this is taken from the MSDN library:
the ASP.NET page framework also supports an automatic way to associate page events and methods. If the AutoEventWireup attribute of the Page directive is set to true (or if it is missing, since by default it is true), 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.
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.
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.
Resource: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconWebFormsEventModel.asp
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: What is AutoEventWireup?
Oct 28, 2005 06:32 PM|LINK
NC...
Niruma
Member
65 Points
11 Posts
Re: What is AutoEventWireup?
Oct 29, 2005 12:18 PM|LINK
To explain it a lil more
If you know VB then remeber what happens if you double click on a button in "desing time" in the code an event procedure
Button_click( ) would come up for you to enter the code.
This is a classic feature of Auto event wireup - and in VB you had to live with it.
But in .NET you can name the event handling function whatever you want and tie up the event with the corresponding handling function.
So if you have a button you could call the MyNewButton_click( ) function. But for this to be possible the "Auto Event Wire-up" property must be set to false at the page level.
Hope this helps [:)]
Niruma
The difference between try and triumph is just a little umph!
Inno
0 Points
2 Posts
Re: What is AutoEventWireup?
Jan 12, 2008 04:32 PM|LINK
Eg. in your .aspx file you can have something like:
[code] [/code]
And in your CodeBehind(.aspx.cs) have
[code] protected void dance_monkey_dance(object sender, System.EventArgs e){ //Stuff } [/code]
Note that the handling function has to be protected, not private, as it is referenced in the markup. However, for AutoEventWireup to work, you still have to use the Page_Load and Page_Init names for those functions.
Cheers,
Inno
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: What is AutoEventWireup?
Jan 13, 2008 10:34 AM|LINK
Inno,
You are replying to a post that is over 2 years old? Why? For what purpose?
NC...
Spider Maste...
Participant
1664 Points
483 Posts
Re: What is AutoEventWireup?
Jan 13, 2008 10:50 AM|LINK
[:S]
WOW
They really do come back from the dead (to the top of the list.)
That sucks big time, Um hello INNO read this please ALL of it >>>> Getting Started
Trading Center is a Continuation of the Classifieds Starter Kit onCode Plex.
Inno
0 Points
2 Posts
Re: What is AutoEventWireup?
Jan 13, 2008 06:10 PM|LINK
I came across this post googling "AutoEventWireup" - it is the first result on Google, so although this post may be long dead in the context of our community, that is far from being true in the wider sense. The post was useful to me, but it also contained some misinformation. I made the call to fix it, granted, at a cost to this community, but hopefully for a greater benefit to all. My sincerest apologies to anyone who didn't get an answer they needed because of this.
-Inno
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: What is AutoEventWireup?
Jan 14, 2008 12:00 PM|LINK
In that case you should start a new post.
NC...
Mr^B
Star
12726 Points
2245 Posts
Re: What is AutoEventWireup?
Jan 14, 2008 01:05 PM|LINK
...and how would that help someone finding this page via a google search and finding mis-information contained within?