Re: How do I update an image without manual refresh?
- From: "Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@xxxxxxxxxxxx>
- Date: Mon, 6 Nov 2006 18:34:55 +0200
The browser will think it is a different image and will get it from the
server.
It doesn't have to be in javascript. If you do it on server side, you can
use the Random class for generating random numbers and adding them to the
image url.
imgControl.ImageUrl = "http://imagePath.jpg?" +
myFunctionThatGetsRandomString();
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Jerry J" <JerryJ@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5D1EC8DA-B7BB-423C-B9E9-436C84A36F4B@xxxxxxxxxxxxxxxx
Eliyahu,
Not sure what you mean here? What happens when the client executes that
JAVA
script?
--
Jerry J
"Eliyahu Goldin" wrote:
You can trick the browser into getting the image from the server rather
than
from the cache by adding a random query parameter to the image source.
I use the following javascript code to generate random numbers:
function random(){
return (new Date()).getMilliseconds();
}
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Jerry J" <JerryJ@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3251161D-A7D0-4FBE-8BC0-26B7790B051A@xxxxxxxxxxxxxxxx
How can I get an asp:Image to refresh when a user uploads a different
jpg.
I disabled caching using this command on Page_Load():
Response.Cache.SetCacheability(HttpCacheability.No Cache);
but it didn't help.
The problem is that this page does not change images after a client
uploads
a new one. If I hit the browser's refresh, then I can see the updated
image,
but if I don't refresh, then I see the previous image.
The code to change the image is this simple: imgControl.ImageUrl =
"http://imagePath.jpg";
The new image does have the same name as the old image, but why should
this
matter? If the browser is caching then why does it work using a
refresh,
wouldn't it still use the image from the cache?
--
Jerry J
.
- Follow-Ups:
- Re: How do I update an image without manual refresh?
- From: Jerry J
- Re: How do I update an image without manual refresh?
- References:
- Re: How do I update an image without manual refresh?
- From: Eliyahu Goldin
- Re: How do I update an image without manual refresh?
- From: Jerry J
- Re: How do I update an image without manual refresh?
- Prev by Date: Re: How do I update an image without manual refresh?
- Next by Date: Re: How do I update an image without manual refresh?
- Previous by thread: Re: How do I update an image without manual refresh?
- Next by thread: Re: How do I update an image without manual refresh?
- Index(es):
Relevant Pages
|