How to Execute Page_Load() in Page's Base Class?

后端 未结 6 859
不知归路
不知归路 2020-12-24 05:56

I have the following PerformanceFactsheet.aspx.cs page class

public partial class PerformanceFactsheet : FactsheetBase
{
    protected void Page_Load(object         


        
6条回答
  •  太阳男子
    2020-12-24 06:40

    Uhm, I maybe wrong, but I believe this is due to inheritance: you are overwriting the FactsheetBase Page_Load method in the derived class.

    In order to have it executed you should do something like

    public partial class PerformanceFactsheet : FactsheetBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load( sender, e );
            // do stuff with the data extracted in FactsheetBase
            divPerformance.Controls.Add(this.Data);
        }
    }
    

    EDIT: n8wrl definitely gave you a cleaner solution (I am not a ASPX programmer).

提交回复
热议问题