|
|
|
start date: Mon, 6 Aug 2007 13:27:11 -0700,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
John Grandy johnagrandy-at-gmail-dot-com
|
|
2
Sergey Poberezovskiy
|
Page_Load in derived classes
If I have UserControlDervied that derives from another UserControlBase , and
in UserControlBase the OnLoad method is overriden , is it necessary to also
override the OnLoad method in UserControlDerived , or can the magic
Page_Load method be used ? Does Page_Load automatically call OnLoad in any
underlying class ?
Date:Mon, 6 Aug 2007 13:27:11 -0700
Author:
|
RE: Page_Load in derived classes
John,
Page_Load is an event which is called by base class, whereas OnLoad is an
override which is executed instead of the base method.
To summarise:
Page_Load event is called in both classes (it is up to the programmer
whether to supply a handler and in which class); those events are independent
and the execution order cannot be guaranteed.
OnLoad overrides base class method, and the code is executed in the
inherited class. It is up to the programmer whether to call base class
(OnLoad) method - which is usually a good practice as there may be other
listeners attached to that.
In this case the programmer can decide whether to execute the custom code
before or after calling the base method.
"John Grandy" wrote:
> If I have UserControlDervied that derives from another UserControlBase , and
> in UserControlBase the OnLoad method is overriden , is it necessary to also
> override the OnLoad method in UserControlDerived , or can the magic
> Page_Load method be used ? Does Page_Load automatically call OnLoad in any
> underlying class ?
>
>
>
Date:Mon, 6 Aug 2007 15:10:03 -0700
Author:
|
|
|