AutoEventWireup is an attribute of the @ Page directive. The AutoEventWireupattribute may have a value of true or false.
You can specify a default value of the AutoEventWireup attribute in several places:
You can specify a default value of the AutoEventWireup attribute in several places:
- The Machine.config file
- The Web.config file
- Individual ASP.NET Web Forms (.aspx files)
- Web User Controls (.ascx files)
When AutoEventWireup is true, ASP.NET does not require that you explicitly bind event handlers to a page event such as Load.
When AutoEventWireup is false, you must explicitly bind the event to a method.
For example, if you have a Page_Load method in the code for a page, the method will be called in response to the Load event only if you write code like this.
public partial class AutoEventWireupExample : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
Response.Write("Executing Page_Load");
}
override protected void OnInit(EventArgs e)
{
this.Load += new System.EventHandler(this.Page_Load);
}
}
No comments:
Post a Comment