View Single Post
  #2 (permalink)  
Old September 13th, 2006, 04:40 PM
ianH ianH is offline
Registered User
Join Date: Sep 2006
Location: , , New Zealand.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

No response to this one yet but I have found a solution, so if anyone is interested:

The problem I had was an imagebutton whose image was created and updated by user actions. A jpg file was saved to the server and then loaded into the imagebutton by code. Unfortunately the new version of the image is not displayed without forcing a refresh. What I discovered was that the image for an imagebutton does not have to be a jpg, gif or other standard graphic file – it can be another aspx page (this is not immediately obvious from the standard resources). So now I draw the image onto an otherwise empty aspx page using objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg). In the main page this is accessed with ImageButton1.ImageUrl= "somepage.aspx?someparameters". And this way it works! I think the reason is that somewhere along the line, aspx files are assumed to be dynamic and so are not cached (unless you overrule this) but other files, like images, are assumed to be static and so are cached (possibly at several levels?) And there doesn’t seem to be a way to change this because there is no way to put directives like Response.CacheControl = "no-cache" into a jpg file. Am I correct?

I’m still not totally happy with this solution though because I have to pass a lot of data between aspx pages (or generate it twice) so if anyone knows of a more elegant (and efficient) way I would be grateful.

Reply With Quote