Refresh image

N

nuhura01

Hi..

I have a button to preview image using the following code, which
preview the image in html page:

Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)

Me.ClearControls(imgMap)
imgMap.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()

I've set the URL for the image at the HTML code of asp web form as
follows:

<asp:Image id="imgMap" runat="server" Height="481px" Width="587px"
ImageUrl="/mySystem/ExportImage.gif"></asp:Image>

The image resides at the server and always be changed based on users'
selection. The first try of clicking the preview button, it works
successfully. However, when the image has been changed, clicking at
the button again will not preview the latest image. It gives the same
image as previously. But, I will only get the latest image when I
click on the IE refresh button. How could I get the latest image
automatically without pressing at the IE refresh button? Anyone can
help me to solve this...?

Thanks for any help..
 
G

Guest

Hi..

I have a button to preview image using the following code, which
preview the image in html page:

Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)

Me.ClearControls(imgMap)
imgMap.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()

I've set the URL for the image at the HTML code of asp web form as
follows:

<asp:Image id="imgMap" runat="server" Height="481px" Width="587px"
ImageUrl="/mySystem/ExportImage.gif"></asp:Image>

The image resides at the server and always be changed based on users'
selection. The first try of clicking the preview button, it works
successfully. However, when the image has been changed, clicking at
the button again will not preview the latest image. It gives the same
image as previously. But, I will only get the latest image when I
click on the IE refresh button. How could I get the latest image
automatically without pressing at the IE refresh button? Anyone can
help me to solve this...?

Thanks for any help..

you can try to add in your Page_Load

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

and see if it helps
 
E

Eliyahu Goldin

The image is cached on client side. You can trick the browser into
re-loading it from the server by adding a random query parameter to the
image url:

ImageUrl="/mySystem/ExportImage.gif +(new Date()).getMilliseconds()"

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
N

nuhura01

you can try to add in your Page_Load

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

and see if it helps- Hide quoted text -

- Show quoted text -

Alexey,

I've tried your code, but it still doesn't work --> it picks-up the
previous image. Any idea??
 
G

Guest

The image is cached on client side. You can trick the browser into
re-loading it from the server by adding a random query parameter to the
image url:

ImageUrl="/mySystem/ExportImage.gif +(new Date()).getMilliseconds()"

a minor change: ImageUrl="/mySystem/ExportImage.gif?" +(new
Date()).getMilliseconds()"
 
N

nuhura01

Theimageis cached on client side. You can trick the browser into
re-loading it from the server by adding a random query parameter to theimageurl:

ImageUrl="/mySystem/ExportImage.gif +(new Date()).getMilliseconds()"

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net




I have a button to previewimageusing the following code, which
preview theimagein html page:
Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)

I've set the URL for theimageat the HTML code ofaspweb form as
follows:
<asp:Imageid="imgMap" runat="server" Height="481px" Width="587px"
ImageUrl="/mySystem/ExportImage.gif"></asp:Image>
Theimageresides at the server and always be changed based on users'
selection. The first try of clicking the preview button, it works
successfully. However, when theimagehas been changed, clicking at
the button again will not preview the latestimage. It gives the same
imageas previously. But, I will only get the latestimagewhen I
click on the IErefreshbutton. How could I get the latestimage
automatically without pressing at the IErefreshbutton? Anyone can
help me to solve this...?
Thanks for any help..- Hide quoted text -

- Show quoted text -

Hi Eliyahu,

I've tried to add a random query parameter to the image url as you
have suggested. But it makes the preview page doesn't show the image
at all... Any idea to solve this???

Thanks in advance for your help.
 
E

Eliyahu Goldin

Just use Alexey's correction, I didn't have time to look in my typing when I
posted the first answer.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Theimageis cached on client side. You can trick the browser into
re-loading it from the server by adding a random query parameter to
theimageurl:

ImageUrl="/mySystem/ExportImage.gif +(new Date()).getMilliseconds()"

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net




I have a button to previewimageusing the following code, which
preview theimagein html page:
Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)

I've set the URL for theimageat the HTML code ofaspweb form as
follows:
<asp:Imageid="imgMap" runat="server" Height="481px" Width="587px"
ImageUrl="/mySystem/ExportImage.gif"></asp:Image>
Theimageresides at the server and always be changed based on users'
selection. The first try of clicking the preview button, it works
successfully. However, when theimagehas been changed, clicking at
the button again will not preview the latestimage. It gives the same
imageas previously. But, I will only get the latestimagewhen I
click on the IErefreshbutton. How could I get the latestimage
automatically without pressing at the IErefreshbutton? Anyone can
help me to solve this...?
Thanks for any help..- Hide quoted text -

- Show quoted text -

Hi Eliyahu,

I've tried to add a random query parameter to the image url as you
have suggested. But it makes the preview page doesn't show the image
at all... Any idea to solve this???

Thanks in advance for your help.
 
J

Joerg Jooss

Thus wrote Alexey,
you can try to add in your Page_Load

Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")
and see if it helps

Making the page non-cacheable won't help. The images are static content and
are served by IIS.

Cheers,
 
J

Joerg Jooss

Thus wrote (e-mail address removed),
Hi..

I have a button to preview image using the following code, which
preview the image in html page:

Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)
Me.ClearControls(imgMap)
imgMap.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()
I've set the URL for the image at the HTML code of asp web form as
follows:

<asp:Image id="imgMap" runat="server" Height="481px" Width="587px"
ImageUrl="/mySystem/ExportImage.gif"></asp:Image>

The image resides at the server and always be changed based on users'
selection. The first try of clicking the preview button, it works
successfully. However, when the image has been changed, clicking at
the button again will not preview the latest image. It gives the same
image as previously. But, I will only get the latest image when I
click on the IE refresh button. How could I get the latest image
automatically without pressing at the IE refresh button? Anyone can
help me to solve this...?

See http://www.joergjooss.de/PermaLink,guid,2316ed51-f87c-4249-924c-99d406ad4bdf.aspx

In order to "touch" the file programmatically, use System.IO.File.SetLastWriteTime().

Cheers,
 
N

nuhura01

Thus wrote (e-mail address removed),










Seehttp://www.joergjooss.de/PermaLink,guid,2316ed51-f87c-4249-924c-99d40...

In order to "touch" the file programmatically, use System.IO.File.SetLastWriteTime().

Cheers,
--
Joerg Jooss
(e-mail address removed)- Hide quoted text -

- Show quoted text -

Thanks Joerg, I've read your article and try it, it works!! The latest
image is showed. But why the browser doesn't automatically resubmit
the information of the system back to me when I click on the IE "Back/
Previous" button? Meaning that I've to click on the Refresh button in
order to get the information.

Another thing that I'm confusing is about the setting for the Custom
HTTP Header Name and Value. What is the purpose of the Custom Header
Value and is the there any standards that I've to follow or I can put
anything?

Thanks a lot for your help...
 
G

Guest

Thanks Joerg, I've read your article and try it, it works!! The latest
image is showed. But why the browser doesn't automatically resubmit
the information of the system back to me when I click on the IE "Back/
Previous" button? Meaning that I've to click on the Refresh button in
order to get the information.

because it use the cache

http://support.microsoft.com/kb/234067
 

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,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top