Override OnLoad() vs. Adding a Load_Handler(), what's the difference?

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

For all the control event handling, one can either override the protected
methods:
OnLoad(EventArgs e),
OnInit(EventArgs e),
OnPreRender(EventArgs e) etc,

or add handler functions like
Load_Handler(object sender, EventArgs e),
Init_Handler(object sender, EventArgs e),
PreRender_Hanlder(object sender, EventArgs e)

and hook them to the Load, Init, PreRender events (e.g. this.Load += new
EventHandler(Load_Handler). What are the scenarios for using one vs. the
other?
 
you can only override once, but can wire up several event handlers.

override is usually used when you want to change the behavior of the method,
event handling is used when some code needs to be notified that the event
has happened (its responding to the event, not changing its meaning).

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top