problem registering events in class heirarchies in asp.net

  • Thread starter Thread starter enantiomer
  • Start date Start date
E

enantiomer

I am using visual studio.net to do my work and I have a base page
class that my other page classes derive from. the base class has on
OnInit method in order to register the InitializeComponent method
which is where vis stud automatically adds event handlers for the
various objects in the asp.net page. My problem is in a class that
derives my base class, i dont know where to add my event handlers for
the new objects of the page. I can't override OnInit again... how do
you deal with this kind of situation?
Thanks,
Jon

public class BasePage: Page
{
..
..
..
protected override void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
}

public class secondPage: BasePage
{
protected System.Web.UI.WebControls.Button myButton;
********where do i add the button to the even handler?*************
..
..
..
}
 
why cant override OnInit again? in the overridden OnInit, just add
base.OnInit()

Abhijeet Dev
 
Back
Top