Master page code executed after child page code

  • Thread starter Thread starter Luigi
  • Start date Start date
L

Luigi

I'm pretty new in asp.net 2.0 and i'm experiencing this problem: in the
master page code i've included some general initialization code common to
all content pages, but when i start debugging this code is executed after
the content pages code... so i cannot actually take advantage from the
master page variables or code... it seems very silly...
There is a solution for this problem?
Thanks,
Luigi
 
You can initialize variables like this:

public partial class MyMasterClass : System.Web.UI.MasterPage

{

private System.Collections.ArrayList myArray = new ArrayList();

...
}

Thanks for the reply, but this method is suitable for simple
initializations, not for example managing request variables, etc.

I've finally found the solution: use the Page_init event in the master page,
that is invoked before the same in the content page.

Hope this can be useful for other having the same issue,

Luigi
 
Luigi,

You can initialize variables like this:

public partial class MyMasterClass : System.Web.UI.MasterPage

{

private System.Collections.ArrayList myArray = new ArrayList();

....
}

Eliyahu
 

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

Back
Top