refresh image in asp.net page

G

Guest

how to refresh a image control to pick up the latest image file on a asp.net
page. i am generating a image based on the input from the user and displaying
it on the page through image control. The problem is that i am not able to
get the latest image on the page, it keeps showing the old page. But when i
hit the refresh button on the toolbar it correctly gets the latest image and
displays it in the control. But that has another problem, it pops up a dialog
asking user whether he wants to retry or cancel...

so in short i need to implement some logic so that the image control is
refreshed when the image changes (i know exactly when the image changes) and
dont popup any dialog box for user input.

any help is greatly appreciated

thanks, Ramendra
 
E

Eliyahu Goldin

You can trick the browser into reloading the image from the server by adding
a random query parameter to the image url. I am using a javascript call that
produces the millisecond part of the current time.

Eliyahu
 
J

Joerg Jooss

Eliyahu said:
You can trick the browser into reloading the image from the server by
adding a random query parameter to the image url. I am using a
javascript call that produces the millisecond part of the current
time.

Or unleash the full power of HTTP by sending a Cache-Control: no-cache
header ;-)

Cheers,
 
G

Guest

Hi Eliyahu,

I have added the query string parameter (page.aspx?a=test) to the image url
but still the image doesn;t seem to get refreshed with the new one.

please clarify you suggestion.

thanks, Ramendra
 
G

Guest

I am new to Asp.net and therefore i am not able to understand your suggestion
or i am doing it in wrong way.

-RK
 
Joined
Dec 22, 2007
Messages
1
Reaction score
0
refresh image

I think what is meant is that the actual image url i.e "www.yoursite.com/images/myImage.jpg" should be appended with something like "www.yoursite.com/images/myImage.jpg?uygwefug=1"

Basically the browser is seeing the same image so returns it from cache so by adding random text on the end your forcing the browser to retrive the new image.

I have had to do this myself and it worked well, the only thing to watch for is if testing to see if the image actually exists first, it will fail if you have params on it.
 
Joined
Oct 5, 2009
Messages
1
Reaction score
0
Refresh image each time

If you add the current time to the link, the link will be unique each time "myImage.jpg?myTime=" & now(). So, it will be refreshed each time.
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top