How to Execute Base Class's Method Before Implementors's Method?
- by DaveDev
I have the following page
public partial class GenericOfflineCommentary : OfflineFactsheetBase
{
}
where OfflineFactsheetBase is defined as
public class OfflineFactsheetBase : System.Web.UI.Page
{
public OfflineFactsheetBase()
{
this.Load += new EventHandler(this.Page_Load);
this.PreInit += new EventHandler(this.Page_PreInit);
}
protected void Page_PreInit(object sender, EventArgs e)
{
if (Request.QueryString["data"] != null)
{
this.PageData = StringCompressor.DecompressString(Request.QueryString["data"]);
this.ExtractPageData();
}
}
}
OfflineFactsheetBase has the following virtual method:
public virtual void ExtractPageData()
{
// get stuff relevant to all pages that impmement OfflineFactsheetBase
}
which is implemented in all pages that impmement OfflineFactsheetBase as follows:
public partial class GenericOfflineCommentary : OfflineFactsheetBase
{
public override void ExtractPageData()
{
// get stuff relevant to an OfflineCommentary page.
}
}
Currently, only GenericOfflineCommentary's ExtractPageData() is firing. How can I modify this to first run OfflineFactsheetBase's ExtractPageData() and then GenericOfflineCommentary's?
edit: I'm trying to avoid having to call base.ExtractPageData() in every implementor. Is this possible?