Timing issues with OnInit in derived class

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

Brock Allen

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....
}
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top