1

my page_load() event is being called twice when my page is loaded.can anyone help me out regarding this? I came to know that if AutoEventWireUp is set to true this happens but that is not the issue here.I even checked it by making the AutoEventWireUp set to false but of no use.I even came to know that if the image tag's src is not specified the page load will be called twice.But no where in my page the image tag src is empty. What might i be missing?

4
  • 2
    can you show your markup page (aspx) and codebehind (aspx.cs) ? Commented Nov 11, 2011 at 10:20
  • hi.. sorry actually we r not supposed to Commented Nov 11, 2011 at 10:23
  • If you check with Fiddler2, is the page actually loading twice (i.e. are there two HTTP requests to it)? Commented Nov 11, 2011 at 10:28
  • i do not have idea regarding "Fiddler2"... there are no two HTTP requests Commented Nov 11, 2011 at 10:35

1 Answer 1

2

It is not you calling the page load function twice, that is the way ASP.NET works. The page posts to itself, thus calling the page_load function, when any Server controls on the page are fired (those which as set to postback).

you can check like this...

if(!IsPostBack) 
{  
    //Code when initial loading 
}
 else 
{ 
// code when post back 
}

taken from here page load is firing twice in asp net page

I hope it will helps you

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.