locked
Image control refreshing at postback when deployed RRS feed

  • Question

  • User-744150743 posted

     I have an image control which behaved perfectly on my local IIS, but after deploying it to my web host, it now refreshes on each postback, making it unacceptably slow.

    The image control represents a map with GPS points drawn on it. It is loaded from another aspx which draws the GPS points on the jpg. It does not change after the initial load. All of my controls are .  I have a smaller image control, a map pointer, which moves to the next GPS point when a button is pressed. I'm suspecting that's not the problem since it could be moved with client script (though here the server script and postback is needed to get the next GPS position and determine if the next map should be loaded). I also have a hidden div which overlaps this control (a "tooltip"-type panel) and is z-ordered in front of it, though it is usually not visible.

     I am new to ASP.NET, so I hope I am not misunderstanding the postback concept.  My understanding is that since the content of the control is not changing, it should not need to be refreshed. It did not seem to refresh when run locally, though it would have been much faster. There is also another image control which I change every so often, which is NOT being refreshed, leading me to think that my map should not have to either.

    Is there a config setting that might be causing this when deployed? Is this a job for AJAX?

    I could put the url here so that you could see what I mean. Is that appropriate?

    Monday, December 1, 2008 12:30 PM

Answers

  • User-744150743 posted

    I found the solution. The reason that my map image was being refreshed with each postback was because it was being generated by another page that saved the altered bitmap to the output stream, ie:

    imgMap.ImageUrl = "LoadImage.aspx"

    Even though this line in the page_load was only being called once when ispostback is false, I noticed that a breakpoint in LoadImage.aspx was being hit on every postback. This was not an artifact of debugging - it was really happening.

    So the lesson here is that if you want to draw graphics on a bitmap image and then use it unchanged across postbacks, first draw the graphics on the  bitmap and save it to a file, then set the ImageUrl to that file, NOT a page that builds the graphics and saves it to the output stream as I had been doing. My page now runs as fast as it did on my local machine.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 1, 2008 11:07 PM

All replies

  • User-477154927 posted

     did you wrap the code that populates the image with this?

    if not page.ispostback then

    'code goes here

    end if

    If you do not specify in the code that it does not need refreshed on postback it will refresh every time.

    Monday, December 1, 2008 2:02 PM
  • User-744150743 posted

     Yes I did wrap it in "if page.ispostback=false" in the page_load. If I put a breakpoint where it loads the Image it happens only once (actually twice), as it is supposed to. But interestingly, if I put a breakpoint in the second LoadImage.aspx which is used to prepare the graphic, it fires on every button_click! I assume this must be some artifact of the debug process in VWD2008 Express.

     I tried moving the hidden div to prevent any overlap - no difference.

    Should I post the URL for you to see this page?

    Monday, December 1, 2008 2:32 PM
  • User-744150743 posted

    I found the solution. The reason that my map image was being refreshed with each postback was because it was being generated by another page that saved the altered bitmap to the output stream, ie:

    imgMap.ImageUrl = "LoadImage.aspx"

    Even though this line in the page_load was only being called once when ispostback is false, I noticed that a breakpoint in LoadImage.aspx was being hit on every postback. This was not an artifact of debugging - it was really happening.

    So the lesson here is that if you want to draw graphics on a bitmap image and then use it unchanged across postbacks, first draw the graphics on the  bitmap and save it to a file, then set the ImageUrl to that file, NOT a page that builds the graphics and saves it to the output stream as I had been doing. My page now runs as fast as it did on my local machine.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 1, 2008 11:07 PM