|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Difference between Page_Load and OnLoadHi everybody,
sorry for the newbie question but I can't get the difference between these two code snippets. Is it that one is a delegate (the first) and that while the first ADDS behaviour the other completely rewrites it? Thanks, Lorenzo public partial class AdminPage : Page { protected void Page_Load(object sender, EventArgs e){//something here} } --- public partial class AdminPage : Page { protected override void OnLoad(EventArgs e){//something here} } You are correct. The really provide the same functionality to the code, but
only the class itself can implement OnLoad. Anything outside must use the Load event and map it to a method. If you use the OnLoad method, you must call the base class's OnLoad, otherwise the event handlers will not be called. <lbologn***@gmail.com> wrote in message Show quoteHide quote news:1118363281.591550.288170@g14g2000cwa.googlegroups.com... > Hi everybody, > > sorry for the newbie question but I can't get the difference between > these two code snippets. Is it that one is a delegate (the first) and > that while the first ADDS behaviour the other completely rewrites it? > > Thanks, > Lorenzo > > public partial class AdminPage : Page > { > protected void Page_Load(object sender, EventArgs e){//something here} > } > --- > public partial class AdminPage : Page > { > protected override void OnLoad(EventArgs e){//something here} > } > Peter Rilling wrote:
> You are correct. The really provide the same functionality to the code, but Hi Peter,> only the class itself can implement OnLoad. Anything outside must use the > Load event and map it to a method. If you use the OnLoad method, you must > call the base class's OnLoad, otherwise the event handlers will not be > called. thanks for the reply Lorenzo Yes,
Load is the event and OnLoad is a method that raises that event when called it's just base class implementation that does it of course, and therefore needs to be called from deriving classes so that events work) -- Show quoteHide quoteTeemu Keiski ASP.NET MVP, AspInsider Finland, EU http://blogs.aspadvice.com/joteke .. <lbologn***@gmail.com> wrote in message news:1118363281.591550.288170@g14g2000cwa.googlegroups.com... > Hi everybody, > > sorry for the newbie question but I can't get the difference between > these two code snippets. Is it that one is a delegate (the first) and > that while the first ADDS behaviour the other completely rewrites it? > > Thanks, > Lorenzo > > public partial class AdminPage : Page > { > protected void Page_Load(object sender, EventArgs e){//something here} > } > --- > public partial class AdminPage : Page > { > protected override void OnLoad(EventArgs e){//something here} > } >
Other interesting topics
Session State stateserver or Sql Server
Did I do this correctly? - Display resized image from DB. Asynchronous Call <Head>Tag PostBack problem HttpWebRequest.GetResponse on POST returns 405 method not allowed Render and get html from usercontrol 2.0 App-Code Folder Support for 'Code-Behind' LDAP Query Help Width of Label |
|||||||||||||||||||||||