Change Image

PROKA

Junior Contributor
Joined
Sep 3, 2003
Messages
249
Location
Bucharest
1 -> I have an image :

Image1.ImageUrl = "image.jpg"


2 -> my page does some operations and replaces that image.jpg with another image.jpg


3 -> the user clicks a "preview" button to see the new image

but the page shows the old image, on page reload. I tried to disable cache, still it doesn't work. It works if I press F5 ( Refresh )

Any ideeas ? :(
 
Run this project
it'll show an image in the ImageBox

now manually change the image.gif file with another image.gif ( you have a directory GIFs to pick from ... just rename and over-write)

and click the button

the image doesn't change :(
 
Last edited:
I see what you mean the only way I have managed to force a change is to use the .image as

Code:
"image.gif?" & Now.ToString

This will work but also means that if the same image appears twice it will be loaded twice and never cached. To test i have used the following code

Code:
        Dim files() As String = IO.Directory.GetFiles(Server.MapPath("gifs"))
        IO.File.Copy(files((Rnd() * UBound(files))), Server.MapPath("image.gif"), True)
        Image1.ImageUrl = "image.gif?" & Now.ToString

Hope that this helps

Andy
 
Thanks it works perfectly with the "?" & Now.ToString ... that's what I needed

thank you again Andy, you kinda rule :)
 
Back
Top