Load Event is Raised Twice

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
 
E

Eliyahu Goldin

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
 
S

Samuel Shulman

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
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top