Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Page_Load in derived classes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Grandy - 06 Aug 2007 21:27 GMT
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 ?
Sergey Poberezovskiy - 06 Aug 2007 23:10 GMT
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.

> 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 ?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.