Question

I have a Master page that inherit this:

public partial class PopupsDashboard : iMasterPageProtected

inside that iMasterPageProtected I make some operations.

I'd like to process these operations before the execution of the Web Form code-behind associated to this Master Page:

<%@ Page Title="" Language="C#" MasterPageFile="~/PopupsDashboard.master" AutoEventWireup="true" CodeFile="Aggrega.aspx.cs" Inherits="interne_appsocial_facebook_aggrega_Aggrega" %>

So I think I need to put the code of Aggrega.aspx.cs not in the Page_Load.

But, where?

Was it helpful?

Solution

The order of events in a page life cycle is this:

  1. MasterPage Init
  2. Page Init
  3. Page Load
  4. MasterPage Load

So, you should put your code in the Init event of your MasterPage

Here is the complete ordered list of events.

The general rule for how events are raised is that the initialization events are raised from the innermost control to the outermost one, and all other events are raised from the outermost control to the innermost one. It is helpful to remember that the master page is merged into the content page and treated as a control in the content page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top