Load Event is Raised Twice

  • Thread starter Thread starter Samuel Shulman
  • Start date Start date
S

Samuel Shulman

Hi

Can anyone explain why the Load Even is raised twice in the web page?

What can be done to avoid it?

Thanks,
Samuel
 
AutoEventWireup is an attribute in @Page directive. Default value is true.
It wires the server controls to event handling methods with matching names
and signatures. For example, if you have a Page_Load method like this

protected void Page_Load(object sender, EventArgs e)

in the code-behind and AutoEventWireup is true, the method will run as the
Page Load event handler.

If you also setup the events yourself with something like

Load += new EventHandler(Page_Load);

or in any other way, the event will be called twice.



--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Samuel Shulman said:
Not sure, where would I set these settings?


Eliyahu Goldin said:
Do you have both automatic event wire-up and explicit server event
setting?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Samuel Shulman said:
Hi

Can anyone explain why the Load Even is raised twice in the web page?

What can be done to avoid it?

Thanks,
Samuel
 
Thank you

I am working on an existing project and I will have to check that

Regards,
Samuel


Eliyahu Goldin said:
AutoEventWireup is an attribute in @Page directive. Default value is true.
It wires the server controls to event handling methods with matching names
and signatures. For example, if you have a Page_Load method like this

protected void Page_Load(object sender, EventArgs e)

in the code-behind and AutoEventWireup is true, the method will run as the
Page Load event handler.

If you also setup the events yourself with something like

Load += new EventHandler(Page_Load);

or in any other way, the event will be called twice.



--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Samuel Shulman said:
Not sure, where would I set these settings?


Eliyahu Goldin said:
Do you have both automatic event wire-up and explicit server event
setting?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Hi

Can anyone explain why the Load Even is raised twice in the web page?

What can be done to avoid it?

Thanks,
Samuel
 
Back
Top