|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Yikes! Where is that initialization code in ASPNET 2.0?In ASPNET 1.X there is a method called InitializeComponent() which clearly wires in the Page_Load method to the Load event, like this: private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } (1) However, in ASPNET 2.0, you will not see this anymore. How am I suppose to know the Page_Load is the correct method? Do you know where they are hiding the code? (2) You can put the Page_Load method, and it is guaranteed to be called. However, I noticed that even if I put the wrong signature such as: void Page_Load() It is still called anyway. Why is that? (Note: Load event has this signature: void Load(object, System.EventArgs ) ASPNET 2.0 gurus please clarify! Thanks (2)
doesn't the specific load function has the signature "handles Page_Load" orso tailing behind the function ? (so there's where they make a difference from the other methods) Show quoteHide quote "PinoyDotnet" wrote: > I am just starting 2.0, so I have this > > > In ASPNET 1.X there is a method called InitializeComponent() which > clearly wires in the Page_Load method to the Load event, like this: > > private void InitializeComponent() > { > this.Load += new System.EventHandler(this.Page_Load); > > } > > (1) > However, in ASPNET 2.0, you will not see this anymore. How am I suppose > to know the Page_Load is the correct method? Do you know where they > are hiding the code? > > > (2) > You can put the Page_Load method, and it is guaranteed to be called. > However, I noticed that even if I put the wrong signature such as: > > void Page_Load() > > > It is still called anyway. Why is that? > > (Note: Load event has this signature: void Load(object, > System.EventArgs ) > > > ASPNET 2.0 gurus please clarify! > > Thanks > > > (1) There are several methods that are automatically called based upon naming > However, in ASPNET 2.0, you will not see this anymore. How am I > suppose > to know the Page_Load is the correct method? Do you know where they > are hiding the code? convention. This list is well documented. This was the way it was in v1.x as well. The three important ones are: Page_PreInit Page_Init Page_Load IIRC, there are about ten in total. With Reflector, go check out the code for System.Web.UI.TemplateControl.HookUpAutomaticHandlersWithNoAssert. > (2) This too was supported in v1.x. It's just a convenience.> You can put the Page_Load method, and it is guaranteed to be called. > However, I noticed that even if I put the wrong signature such as: > void Page_Load() > > It is still called anyway. Why is that? -Brock DevelopMentor http://staff.develop.com/ballen |
|||||||||||||||||||||||