2

When I click the Button I am loading one page. i am having some controls in the page_load.

but the problem is my page_load is hitting more than once.

Please can any body explain me what could be the possible reasons for hitting the page_load multiple times.

Thanks

Sandy
  • 105
  • 7

3 Answers3

5

Is hitting Page_Load twice your issue?

Most probably its due to asp:Image or img without src defined.

To quote mbanavige of ASP.NET Forums,

if you have an img tag with an empty/missing src attribute, then the browser may re-request the current page (or may request the default page) why trying to satisfy the empty src for that img tag.

Another possibility that occurs from time to time is that the page_load event has been wired up twice.

Related: page loads twice in Google chrome

Community
  • 1
  • 1
naveen
  • 53,448
  • 46
  • 161
  • 251
3

This is by design. In the page life-cycle it is called on the initial request and on the postback.

http://msdn.microsoft.com/en-us/library/ms178472.aspx

IrishChieftain
  • 15,108
  • 7
  • 50
  • 91
1

ASP.NET webforms are self-posting, so Page_Load will hit hit everytime a time a post back occurs. If you would like to only execute certain code on initial page load, add the following to your Load event handler:

if (!Page.IsPostback)
{
 // Code here
}

This says only execute this code if this is the first request to this page.

Ta01
  • 31,040
  • 13
  • 70
  • 99