What is AUTOEVENTWIREUP?
When to use AutoEventWireup="True"?
Just imagine there is a button with name "Button1" in a web page.
If the user clicked that button, a message "hello" should be displayed.
How you will write code for this job?
<asp:button id="Button1" OnClick="Button1_Click" />
Here the Button1's Click EVENT is WIRED to Button1_Click Method.
If you remove the words OnClick="Button1_Click" in the above code,
then the method will NOT be called. Because there is no wiring (no binding) between the Event and the Method.
But AutoEventWireup=true means, the program should
automatically understand that the method "Button1_Click" is intended for the Click Event of Button1 and
it should AUTOMATCALLY call this method.
The above example is just to explain the meaning f EVENT and WIREUP.
In actual sense, even if AutoEventWireup=True,even then OnClick="SomeMethodName" is a must.
Because the AutoEventWireup is applicable only to Page Events such as Page_Load,Page_Unload,Page_Init.
And AutoEventWireup is Not Applicable to other things such as Button,etc.
Put together, if you use AutoEventWireup="False" then, you have to SPECIFICALLY call the
Page_Load to use this method. The example of how to call the Page_Load method is given Below:
public partial class
_Default : Page
Load += new EventHandler(Page_Load);
protected void Page_Load(object
sender, EventArgs e)