By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,649 Members | 1,765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,649 IT Pros & Developers. It's quick & easy.

Refresh image

P: n/a
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..

Feb 26 '07 #1
Share this Question
Share on Google+
11 Replies


P: n/a
On Feb 26, 7:52 am, nuhur...@yahoo.com wrote:
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

Feb 26 '07 #2

P: n/a
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
<nu******@yahoo.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
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..

Feb 26 '07 #3

P: n/a
On Feb 25, 11:11 pm, "Alexey Smirnov" <alexey.smir...@gmail.com>
wrote:
On Feb 26, 7:52 am, nuhur...@yahoo.com wrote:


Hi..
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)
Me.ClearControls(imgMap)
imgMap.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()
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..

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??

Feb 26 '07 #4

P: n/a
On Feb 26, 8:31 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
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()"

Feb 26 '07 #5

P: n/a
On Feb 25, 11:31 pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
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

<nuhur...@yahoo.comwrote in message

news:11**********************@q2g2000cwa.googlegro ups.com...
Hi..
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)
Me.ClearControls(imgMap)
imgMap.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()
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.
Feb 26 '07 #6

P: n/a
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
<nu******@yahoo.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
On Feb 25, 11:31 pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
>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

<nuhur...@yahoo.comwrote in message

news:11**********************@q2g2000cwa.googlegr oups.com...
Hi..
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)
Me.ClearControls(imgMap)
imgMap.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()
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.


Feb 26 '07 #7

P: n/a
Thus wrote Alexey,
On Feb 26, 7:52 am, nuhur...@yahoo.com wrote:
>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
Making the page non-cacheable won't help. The images are static content and
are served by IIS.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Feb 26 '07 #8

P: n/a
Thus wrote nu******@yahoo.com,
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,g...406ad4bdf.aspx

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

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Feb 26 '07 #9

P: n/a
On Feb 26, 1:36 pm, Joerg Jooss <news-re...@joergjooss.dewrote:
Thus wrote nuhur...@yahoo.com,


Hi..
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)
Me.ClearControls(imgMap)
imgMap.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()
I've set the URL for theimageat the HTML code of asp web 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...?

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
news-re...@joergjooss.de- 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...

Feb 27 '07 #10

P: n/a
On Feb 27, 2:28 am, nuhur...@yahoo.com wrote:
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

Feb 27 '07 #11

P: n/a
On Feb 27, 10:19 am, "Alexey Smirnov" <alexey.smir...@gmail.com>
wrote:

because it used the cache
Feb 27 '07 #12

This discussion thread is closed

Replies have been disabled for this discussion.