Page_Load called twice???

  • Thread starter Thread starter Andy
  • Start date Start date
A

Andy

Visual Studio 2003 web form problem using C#.

My Page_Load or OnInit routines seems to be called twice
for every post back to the server.

I have 2 web forms that produce this behaviour, all of
the others just run these routines once.

Any ideas!
 
Is it Page_Load, OnInit, or both? If it's just Page_Load, check if those
two forms have AutoEventWireup="true" in addition to VS.NET's
InitializeComponents() code to attach Page_Load to the OnLoad event.
 
I think it's the Oninit thats being called twice, the
sequence of events is as follows

This bit of code is fired first-

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

then the Page_Load is fired
then back to OnInit
then back to Page_Load

All pages have AutoEventWireup set to false.

Cheers Andy
 
Back
Top