Timing issues with OnInit in derived class

  • Thread starter Thread starter tatemononai
  • Start date Start date
T

tatemononai

I've got a asp.net page that is derived off a custom class. The base
class does some init stuff in OnInit that is needed by the derived
pages. I'm having a timing problem with OnInit. The OnInit in the
derived classes executes BEFORE the OnInit in the base class. I need
it to be the other way around. How can I fix this?
 
I've got a asp.net page that is derived off a custom class. The base
class does some init stuff in OnInit that is needed by the derived
pages. I'm having a timing problem with OnInit. The OnInit in the
derived classes executes BEFORE the OnInit in the base class. I need
it to be the other way around. How can I fix this?

In your derived class' OnInit, call base.OnInit prior to doing the work that
replies upon the base's implementation.

// base.cs

override void OnInit(EventArgs e)
{
base.OnInit(e);

// Your stuff here....
}

-Brock
http://staff.develop.com/ballen
 
Back
Top