Page_Load question

  • Thread starter Thread starter Andrea Williams
  • Start date Start date
A

Andrea Williams

When I step through my code, the code in the OnInit function is executed
twice. Is that normal?


Andrea
 
When I step through my code, the code in the OnInit function is executed
twice. Is that normal?

No.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
No, it is not. Are you sure the page you are tracing/debugging is
requested only once?

Also, check out the stack trace to see if you can find more information
which may lead to answers.
 
Ok, so what could be acusing this to happen. I've stepped through the code
and do not see and response . redirects, or .execute or anything else that
might tell the page to reload. It just goes all the way through to the
OnUnload and then starts back at the OnInit routine again. I'm puzzled...

Andrea
 
the default page is the page where the code is being executed twice. When I
stepped through a different page in the same folder of the project
(faq.aspx), all the code in the FAQ.ASPX.cs executed and then the code from
default.aspx.cs executed (NS._default). My logging mechanism is also
recording that both pages have been hit, even though I only loaded faq.aspx.

Yes, I'm sure that only one is executed, I'm the only one on this test box.

Andrea
 
I think narrowed in on the line of code that caused the problem, although I'm still puzzled as to why it caused the behavior. There was a line in my client side java script for my Menu. I have no idea why, but consistantly taking out and putting the line back in allowed me to determine that it was in fact that particular line. It was trying to add an empty variable (so I wasn't using it anyway) into an array. So I added an if clause around it so it was only popuated when the variable wasn't empty.

Again, I have no idea why it caused a problem, but it did.

Andrea

objSTMenu[currentGroupIndex].menus[currentMenuIndex].items[currentItemIndex]=new Object();

var tempObj=objSTMenu[currentGroupIndex].menus[currentMenuIndex].items[currentItemIndex];
tempObj.sepLineImageSrc=sepLineImage; //sepLineImage is an input variable

tempObj.sepLineImage=new Image();

if ((sepLineImage != null) && (sepLineImage != "")) //Added to prevent ASP.NET code reload

tempObj.sepLineImage.src=sepLineImage;

tempObj.sepLineWidth=sepLineWidth=="" ? 0 : eval(sepLineWidth);

tempObj.lineImageWidth =lineImageWidth== "" ? -1 : eval(lineImageWidth);

tempObj.lineImageHeight=lineImageHeight=="" ? -1 : eval(lineImageHeight);
 
Back
Top