0

I tracked down a very weird ... bug...

I found that for some reason, an ASPX page always executed twice.

I tracked it down to this line in a user (asxc) control, I had :

<img src='<%=RS("buildhover")%>'  />

RS is just a helper function that resolves to ResouceManager.GetString("buildhover")

I found that "buildhover" was simply missing from the resx file that was being read. When added, the ASPX page is no longer run twice...

This is very strange and since I use resource files extensively, I am really interested to find out why this is...

Greg Bala
  • 3,563
  • 7
  • 33
  • 43

2 Answers2

1

When you have an image element with a blank url for the string then it makes a request to the current page. When the resource doesn't exist you get a blank string. So the result of ResouceManager.GetString("buildhover") is an empty string.

Look at the html produced. You will have something like <img src="" />

kmcc049
  • 2,783
  • 17
  • 13
  • yea thank you, that was it! I never, in my wildest dreams, woudl thinkg that scr='' woudl cause a double laod... thought it must have been releated to the resources manager... thanks again! – Greg Bala Oct 04 '11 at 20:12
0

If you are observing load event twice in a post back in ASP.Net page, check the following:

1.If Page_Load handler defined in Codebehind then AutoEventWireup property should be “false”

  1. Check if you have mistakenly multiple event handlers registered for an event
  2. Src or ImageURL attribute of your image control are defined and not empty (you can put %20 for blank)
  3. bgColor or background is empty

Last two problems usually appears in one browser while disappears in other.

http://devshop.wordpress.com/2008/06/02/aspnet-page-loading-twice/

Adnan Bhatti
  • 3,410
  • 4
  • 25
  • 38