473,419 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Force browser to refresh?

I have a page that displays a picture. In the page load I figure out which
image and then do a StudentPicutre.imageurl = <some file name>

But if you use the browser's back button, enter different criteria, then
click the view button, the code runs to load a different picture, but the
old one shows up until I hit the browser's refresh button.

What am I doing wrong? How do I force the browser to load the new image?

Thanks,
---Selden McCabe
Nov 19 '05 #1
5 13073
To prevent caching, use this code:

Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Selden McCabe" <se*****@msn.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have a page that displays a picture. In the page load I figure out which
image and then do a StudentPicutre.imageurl = <some file name>

But if you use the browser's back button, enter different criteria, then
click the view button, the code runs to load a different picture, but the
old one shows up until I hit the browser's refresh button.

What am I doing wrong? How do I force the browser to load the new image?

Thanks,
---Selden McCabe

Nov 19 '05 #2
I tried putting this in the page_load event, but it didn't have any effect.
When I do back, select a different student, then click view, I see the old
one
until I click the browser's refresh.

Where should I put this code?

Thanks!
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
To prevent caching, use this code:

Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Selden McCabe" <se*****@msn.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have a page that displays a picture. In the page load I figure out
which image and then do a StudentPicutre.imageurl = <some file name>

But if you use the browser's back button, enter different criteria, then
click the view button, the code runs to load a different picture, but the
old one shows up until I hit the browser's refresh button.

What am I doing wrong? How do I force the browser to load the new image?

Thanks,
---Selden McCabe


Nov 19 '05 #3
One trick is to use a QueryString in the image tag, with some differing
value each time the image is displayed. It doesn't affect the image, but
fools the browser into thinking it is downloading a different resource.
Example:

<img src="someimage.jpg?q=1">
<img src="someimage.jpg?q=2">
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Selden McCabe" <se*****@msn.com> wrote in message
news:#O**************@tk2msftngp13.phx.gbl...
I have a page that displays a picture. In the page load I figure out which image and then do a StudentPicutre.imageurl = <some file name>

But if you use the browser's back button, enter different criteria, then
click the view button, the code runs to load a different picture, but the
old one shows up until I hit the browser's refresh button.

What am I doing wrong? How do I force the browser to load the new image?

Thanks,
---Selden McCabe

Nov 19 '05 #4
Page_Load is fine.
You should manually clear your browser cache, because it's likely still in
your cache from before you put the code in.
I'm assuming you're pointing to a standard image file like a jpg or gif.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Selden McCabe" <se*****@msn.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I tried putting this in the page_load event, but it didn't have any effect.
When I do back, select a different student, then click view, I see the old
one
until I click the browser's refresh.

Where should I put this code?

Thanks!
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
To prevent caching, use this code:

Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Selden McCabe" <se*****@msn.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have a page that displays a picture. In the page load I figure out
which image and then do a StudentPicutre.imageurl = <some file name>

But if you use the browser's back button, enter different criteria, then
click the view button, the code runs to load a different picture, but
the old one shows up until I hit the browser's refresh button.

What am I doing wrong? How do I force the browser to load the new
image?

Thanks,
---Selden McCabe



Nov 19 '05 #5
Thank you, Kevin!

Somehow I forgot that I was always using "images\temp.jpeg" for the file
name,
so of course the browser didn't know I was changing the image each time.

Once I got your suggestion, I changed it to:
"images\temp.jpeg?current=" + DateTime.Now

and it's working fine.

Thanks for the help!!!!
---Selden
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:OO**************@TK2MSFTNGP14.phx.gbl...
One trick is to use a QueryString in the image tag, with some differing
value each time the image is displayed. It doesn't affect the image, but
fools the browser into thinking it is downloading a different resource.
Example:

<img src="someimage.jpg?q=1">
<img src="someimage.jpg?q=2">
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Selden McCabe" <se*****@msn.com> wrote in message
news:#O**************@tk2msftngp13.phx.gbl...
I have a page that displays a picture. In the page load I figure out

which
image and then do a StudentPicutre.imageurl = <some file name>

But if you use the browser's back button, enter different criteria, then
click the view button, the code runs to load a different picture, but the
old one shows up until I hit the browser's refresh button.

What am I doing wrong? How do I force the browser to load the new image?

Thanks,
---Selden McCabe


Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: vickie_raven | last post by:
is there any way to force a refresh of a page that a user visits?? sorry i am still learning. vickie
19
by: Jay | last post by:
I'm trying to refresh browser when some new information is available in DB. is there any way to force to refresh browser? Thanks. -Kev
7
by: milkyway | last post by:
Hello to all ;-) I am using the Visual Studio 2005 .NET framework. Basically, I have file that is served up as an HTML file on the client side (generated from a .aspx file). But - the HTML...
1
by: Marco Maroni | last post by:
How to force image refresh on client browser ? Is ti possible to force the refresh of the same image (tha was changed server-side) to the client, without user press Contrl+F5 in IE ? - Marco
2
by: Jaikanth Sithambaranathan via .NET 247 | last post by:
The problem is in the result page in which i can scroll throughthe contents of the result set 100 at a time. I call the resultpage from a filter page where i accept filter on results to bedisplayed....
10
by: Fred Nelson | last post by:
Hi: I have a VB.NET web application and I need to find a way to cause a page refresh from within my application. Does anyone know how to force the browser to refresh the current page? ...
1
by: Dabbler | last post by:
What effect does the browser refresh button have on a) session variables and b) viewstate? My page loads info based on session variables and it seems this breaks when someone does a page...
2
by: pingalkar | last post by:
In my application, on one form i m getting information from user and save this information , after saving this information again we loading that page. (At this moment if any one try to refresh this...
0
by: neo2020 | last post by:
Hi all, Is it possible for us to detect the browser refresh event ? I am thinking of comparing the current browser loaded URL with the target url. If they are the same, then imply it is an refresh...
3
by: COHENMARVIN | last post by:
I have a button in my asp.net page (actually its in a user control with a .ASCX suffix) called btnGetData. I'm trying to make it force a refresh of my page. So what I did was make it call...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.