. ASP.NET pages automatically bind page events to methods that have the name Page_event. This automatic binding is configured by the AutoEventWireup attribute in the @ Page directive, which is set to true by default. If you set AutoEventWireup to false, the page does not automatically search for methods that use the Page_event naming convention.
So, if I wanted to handle the Page Init event, I just need to add this and the event gets bound automatically.
protected void Page_Init() {
Trace.Write("I am in init!");
}
Trace.Write("I am in init!");
}
.AutoEventWireup="true" target is for page events only. In case of AutoEventWireup method are not case sensitive. (Page_Load or page_load both will work).
If AutoEventWireup="false" but still you want to executed Page event (Page_Load). In this you have to explicitly code for it.
<form id="form1" runat="server" onload="Page_Load">
No comments:
Post a Comment