This is related to another post I submitted, but I'll be more precise this
time.
I have a web page that contains an Image webcontrol that loads its image by:
Image1.ImageUrl ="<username>.jp g", and an option for the user to update the
photo. If they click the update button, I then flip up a new panel, where I
have a FileUpload control and corresponding Upload Button. If they load an
image file and click the Upload button, my code uses the
FileUpload1.Sav eAs(...), saving to "<username>_tem p.jpg", and then load the
image in another Image control (Image2) that I use for a preview area for
the user. They can re-upload as many preview photos they want and each time
the FileUpload1.Sav eAs(...) command saves the image to "<username>_tem p.jpg"
and the preview image always updates correctly. But when the user clicks
the final "Save Image" button to return to the original panel, I'm left with
their latest photo named "<username>_tem p.jpg", which I then save as
"<username>.jpg ", and re-update the original Image control (Image1). The
problem is, the original Image control, still keeps pointing to the cached
Image I loaded when the page originally loaded.
So my question is, how do I dynamically (in code) delete the temp image file
that's being held in cache or cause it to expire so that the new photo gets
updated. When I use the "FileUpload1.Sa veAs(...)" command, it is doing
something somehow to make my preview Image control work properly.
Any help? 9 1870
On 10/21/06 15:20, Mark Denardo wrote:
This is related to another post I submitted, but I'll be more precise this
time.
I have a web page that contains an Image webcontrol that loads its image by:
Image1.ImageUrl ="<username>.jp g", and an option for the user to update the
photo. If they click the update button, I then flip up a new panel, where I
have a FileUpload control and corresponding Upload Button. If they load an
image file and click the Upload button, my code uses the
FileUpload1.Sav eAs(...), saving to "<username>_tem p.jpg", and then load the
image in another Image control (Image2) that I use for a preview area for
the user. They can re-upload as many preview photos they want and each time
the FileUpload1.Sav eAs(...) command saves the image to "<username>_tem p.jpg"
and the preview image always updates correctly. But when the user clicks
the final "Save Image" button to return to the original panel, I'm left with
their latest photo named "<username>_tem p.jpg", which I then save as
"<username>.jpg ", and re-update the original Image control (Image1). The
problem is, the original Image control, still keeps pointing to the cached
Image I loaded when the page originally loaded.
So my question is, how do I dynamically (in code) delete the temp image file
that's being held in cache or cause it to expire so that the new photo gets
updated. When I use the "FileUpload1.Sa veAs(...)" command, it is doing
something somehow to make my preview Image control work properly.
Any help?
I have only a couple thoughts on this. First, the content is cached by the
client, not the server. When the content is served to the client, it gets
an expiration date/time. As far as I know, you can't tell the client to
remove any content from its cache.
What I've seen people do in other applications is name the content such
that you can simply change the name when you have updated it. For example,
name the .jpg file with a unique name, then update the HTML generation
code to use the generated name.
This way, the client can cache the content for a long period of time, and
if you decide you want the client to get new content, all you have to do
is change the name of the file.
If you change the expiration date of the content, the client will still
have the original expiration, and will not even request the new content,
so the updated expiration will never be noticed.
I'm not sure why your preview is not suffering from the same problem.
Is the file name really <username>_temp .jpg, or by "temp" did you mean
it was a unique set of characters?
If the file names are identical, then perhaps the application is serving
this temp content with a really short expiration period? If that is so,
you don't want to do the same thing with your actual content, or it will
never be able to take advantage of the cache on the client.
Hope that helps,
Mark,
as Mark H alluded, this can often be solved by making the url to the image
unque, for example:
Image1.ImageUrl ="<username>.jp g?id="+DateTime .Now.Ticks.ToSt ring();
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Mark Denardo" wrote:
This is related to another post I submitted, but I'll be more precise this
time.
I have a web page that contains an Image webcontrol that loads its image by:
Image1.ImageUrl ="<username>.jp g", and an option for the user to update the
photo. If they click the update button, I then flip up a new panel, where I
have a FileUpload control and corresponding Upload Button. If they load an
image file and click the Upload button, my code uses the
FileUpload1.Sav eAs(...), saving to "<username>_tem p.jpg", and then load the
image in another Image control (Image2) that I use for a preview area for
the user. They can re-upload as many preview photos they want and each time
the FileUpload1.Sav eAs(...) command saves the image to "<username>_tem p.jpg"
and the preview image always updates correctly. But when the user clicks
the final "Save Image" button to return to the original panel, I'm left with
their latest photo named "<username>_tem p.jpg", which I then save as
"<username>.jpg ", and re-update the original Image control (Image1). The
problem is, the original Image control, still keeps pointing to the cached
Image I loaded when the page originally loaded.
So my question is, how do I dynamically (in code) delete the temp image file
that's being held in cache or cause it to expire so that the new photo gets
updated. When I use the "FileUpload1.Sa veAs(...)" command, it is doing
something somehow to make my preview Image control work properly.
Any help?
No the temp files will always have same same [ex. User1_temp.jpg], that's
what's so puzzling to me. What is the .SaveAs command doing that I could be
doing as well...
"Mark E. Hansen" <me*@NOSPAMunif y.comwrote in message
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
On 10/21/06 15:20, Mark Denardo wrote:
>This is related to another post I submitted, but I'll be more precise this time.
I have a web page that contains an Image webcontrol that loads its image by: Image1.ImageUr l="<username>.j pg", and an option for the user to update the photo. If they click the update button, I then flip up a new panel, where I have a FileUpload control and corresponding Upload Button. If they load an image file and click the Upload button, my code uses the FileUpload1.Sa veAs(...), saving to "<username>_tem p.jpg", and then load the image in another Image control (Image2) that I use for a preview area for the user. They can re-upload as many preview photos they want and each time the FileUpload1.Sav eAs(...) command saves the image to "<username>_te mp.jpg" and the preview image always updates correctly. But when the user clicks the final "Save Image" button to return to the original panel, I'm left with their latest photo named "<username>_tem p.jpg", which I then save as "<username>.jp g", and re-update the original Image control (Image1). The problem is, the original Image control, still keeps pointing to the cached Image I loaded when the page originally loaded.
So my question is, how do I dynamically (in code) delete the temp image file that's being held in cache or cause it to expire so that the new photo gets updated. When I use the "FileUpload1.Sa veAs(...)" command, it is doing something somehow to make my preview Image control work properly.
Any help?
I have only a couple thoughts on this. First, the content is cached by the
client, not the server. When the content is served to the client, it gets
an expiration date/time. As far as I know, you can't tell the client to
remove any content from its cache.
What I've seen people do in other applications is name the content such
that you can simply change the name when you have updated it. For example,
name the .jpg file with a unique name, then update the HTML generation
code to use the generated name.
This way, the client can cache the content for a long period of time, and
if you decide you want the client to get new content, all you have to do
is change the name of the file.
If you change the expiration date of the content, the client will still
have the original expiration, and will not even request the new content,
so the updated expiration will never be noticed.
I'm not sure why your preview is not suffering from the same problem.
Is the file name really <username>_temp .jpg, or by "temp" did you mean
it was a unique set of characters?
If the file names are identical, then perhaps the application is serving
this temp content with a really short expiration period? If that is so,
you don't want to do the same thing with your actual content, or it will
never be able to take advantage of the cache on the client.
Hope that helps,
Bada Bing, that worked!
Many thanks -- Mark
"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com wrote in message
news:F8******** *************** ***********@mic rosoft.com...
Mark,
as Mark H alluded, this can often be solved by making the url to the image
unque, for example:
Image1.ImageUrl ="<username>.jp g?id="+DateTime .Now.Ticks.ToSt ring();
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Mark Denardo" wrote:
>This is related to another post I submitted, but I'll be more precise this time.
I have a web page that contains an Image webcontrol that loads its image by: Image1.ImageUr l="<username>.j pg", and an option for the user to update the photo. If they click the update button, I then flip up a new panel, where I have a FileUpload control and corresponding Upload Button. If they load an image file and click the Upload button, my code uses the FileUpload1.Sa veAs(...), saving to "<username>_tem p.jpg", and then load the image in another Image control (Image2) that I use for a preview area for the user. They can re-upload as many preview photos they want and each time the FileUpload1.Sav eAs(...) command saves the image to "<username>_te mp.jpg" and the preview image always updates correctly. But when the user clicks the final "Save Image" button to return to the original panel, I'm left with their latest photo named "<username>_tem p.jpg", which I then save as "<username>.jp g", and re-update the original Image control (Image1). The problem is, the original Image control, still keeps pointing to the cached Image I loaded when the page originally loaded.
So my question is, how do I dynamically (in code) delete the temp image file that's being held in cache or cause it to expire so that the new photo gets updated. When I use the "FileUpload1.Sa veAs(...)" command, it is doing something somehow to make my preview Image control work properly.
Any help?
On 10/21/06 17:17, Mark Denardo wrote:
Bada Bing, that worked!
Of course, this solution will result in that particular image never
being cached - even if you never change it again. This could pose
a large performance penalty.
For example, if you were to do this trick with a photo album, it
will have to serve the pictures each time you visit the page.
If that's okay for your application, then you needed do any more.
Best,
>
Many thanks -- Mark
"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com wrote in message
news:F8******** *************** ***********@mic rosoft.com...
>Mark, as Mark H alluded, this can often be solved by making the url to the image unque, for example: Image1.ImageUr l ="<username>.jp g?id="+DateTime .Now.Ticks.ToSt ring();
Peter -- Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com
"Mark Denardo" wrote:
>>This is related to another post I submitted, but I'll be more precise this time.
I have a web page that contains an Image webcontrol that loads its image by: Image1.ImageU rl="<username>. jpg", and an option for the user to update the photo. If they click the update button, I then flip up a new panel, where I have a FileUpload control and corresponding Upload Button. If they load an image file and click the Upload button, my code uses the FileUpload1.S aveAs(...), saving to "<username>_tem p.jpg", and then load the image in another Image control (Image2) that I use for a preview area for the user. They can re-upload as many preview photos they want and each time the FileUpload1.Sav eAs(...) command saves the image to "<username>_t emp.jpg" and the preview image always updates correctly. But when the user clicks the final "Save Image" button to return to the original panel, I'm left with their latest photo named "<username>_tem p.jpg", which I then save as "<username>.j pg", and re-update the original Image control (Image1). The problem is, the original Image control, still keeps pointing to the cached Image I loaded when the page originally loaded.
So my question is, how do I dynamically (in code) delete the temp image file that's being held in cache or cause it to expire so that the new photo gets updated. When I use the "FileUpload1.Sa veAs(...)" command, it is doing something somehow to make my preview Image control work properly.
Any help?
There is a way to keep the benefits of the caching, and still defeat the
cache when updating the image. That is to keep a version number for the
image, and use that in the url:
Image1.ImageUrl = "<username>.jpg ?v=" + version.ToStrin g();
Mark E. Hansen wrote:
On 10/21/06 17:17, Mark Denardo wrote:
>Bada Bing, that worked!
Of course, this solution will result in that particular image never
being cached - even if you never change it again. This could pose
a large performance penalty.
For example, if you were to do this trick with a photo album, it
will have to serve the pictures each time you visit the page.
If that's okay for your application, then you needed do any more.
Best,
>Many thanks -- Mark
"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com wrote in message news:F8******* *************** ************@mi crosoft.com...
>>Mark, as Mark H alluded, this can often be solved by making the url to the image unque, for example: Image1.ImageU rl ="<username>.jp g?id="+DateTime .Now.Ticks.ToSt ring();
Peter -- Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com
"Mark Denardo" wrote:
This is related to another post I submitted, but I'll be more precise this time.
I have a web page that contains an Image webcontrol that loads its image by: Image1.Image Url="<username> .jpg", and an option for the user to update the photo. If they click the update button, I then flip up a new panel, where I have a FileUpload control and corresponding Upload Button. If they load an image file and click the Upload button, my code uses the FileUpload1. SaveAs(...), saving to "<username>_tem p.jpg", and then load the image in another Image control (Image2) that I use for a preview area for the user. They can re-upload as many preview photos they want and each time the FileUpload1.Sav eAs(...) command saves the image to "<username>_ temp.jpg" and the preview image always updates correctly. But when the user clicks the final "Save Image" button to return to the original panel, I'm left with their latest photo named "<username>_tem p.jpg", which I then save as "<username>. jpg", and re-update the original Image control (Image1). The problem is, the original Image control, still keeps pointing to the cached Image I loaded when the page originally loaded.
So my question is, how do I dynamically (in code) delete the temp image file that's being held in cache or cause it to expire so that the new photo gets updated. When I use the "FileUpload1.Sa veAs(...)" command, it is doing something somehow to make my preview Image control work properly.
Any help?
On 10/21/06 21:35, Göran Andersson wrote:
There is a way to keep the benefits of the caching, and still defeat the
cache when updating the image. That is to keep a version number for the
image, and use that in the url:
Image1.ImageUrl = "<username>.jpg ?v=" + version.ToStrin g();
Yes, that was already recommended earlier in the thread...
Mark E. Hansen wrote:
On 10/21/06 21:35, Göran Andersson wrote:
>There is a way to keep the benefits of the caching, and still defeat the cache when updating the image. That is to keep a version number for the image, and use that in the url:
Image1.ImageUr l = "<username>.jpg ?v=" + version.ToStrin g();
Yes, that was already recommended earlier in the thread...
Do you mean the suggestion by Peter Bromberg? That is not at all the
same, as that defeats the caching entirely, while my suggestion only
defeats the caching when you update the image.
On 10/22/06 10:22, Göran Andersson wrote:
Mark E. Hansen wrote:
>On 10/21/06 21:35, Göran Andersson wrote:
>>There is a way to keep the benefits of the caching, and still defeat the cache when updating the image. That is to keep a version number for the image, and use that in the url:
Image1.ImageU rl = "<username>.jpg ?v=" + version.ToStrin g();
Yes, that was already recommended earlier in the thread...
Do you mean the suggestion by Peter Bromberg? That is not at all the
same, as that defeats the caching entirely, while my suggestion only
defeats the caching when you update the image.
Actually, I was referring to my post, where in I said:
What I've seen people do in other applications is name the content such
that you can simply change the name when you have updated it. For example,
name the .jpg file with a unique name, then update the HTML generation
code to use the generated name.
The point is that it allowed the application to decide when the image
should be fetched by the client, rather than having the image never
get cached. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sentinel |
last post by:
Hello,
I'm having problems refreshing a main window, and am not sure really
whether the solution will be Javascript or PHP related.
Firstly, I have a main file that calls a pop-up box which enables
comments to be made about certain images on the page. The pop-up makes
a connection to a MySQL database and the existing comments are put
into a PHP array and echoed to the screen.
|
by: A.Translator |
last post by:
I have been struggling with a page that is based on a table structure
(because that is all I am feeling comfortable with at the moment) styled
with css.
One of the problems I run in to is Opera (Opera 7 in my case).
The weird thing is: viewing the page through Opera's eyes the first time
around is OK, but after refreshing, the page gets messed up badly.
I will look into the cause of the mess, but for now am really curious:
what does...
|
by: jdi |
last post by:
Hello,
I have a seemingly basic question about ASP.NET. I would like to
create a page containing an image, which keeps swapping the url of the
image source, without refreshing the entire page. So when the page
first loads I'd like the image url to be "img1.gif"; then 20 seconds
later "img2.gif"; then "img3.gif", and so on. All this should take
place dynamically without refreshing the page.
Any help would be appreciated.
|
by: Jeronimo Bertran |
last post by:
Hi,
I have a page that includes an image that uses an image map. When the
user clicks on a button, the image needs to be refreshed and the map needs
to be updated without refreshing the entire form.
<img id="mapimage" src="renderimage.aspx?param=1" usemap="#mappoints">
<map name ="mappoints>
<area......>
</map>
|
by: Jensen Bredal |
last post by:
Hello,
I need to display self refreshing information on a web page written with
asp.net. I would image that the info would be displayed either as part of a
user control or a web control.
How can this be done? The information will come from a database and the
displaying should loop throug a table in
the database.
Many thank in advance
JB
| |
by: Mark Denardo |
last post by:
I created a Web Image "<asp:Image ID="Image1" ..." that my code behind set
to a certain image file say image1.jpg
=Image1.ImageUrl = "<rel_path>/image1.jpg";
which set the image ok, but then I replaced that image file with another
image file and gave it the same name "image1.jpg". But my web app when it
loads the image when I run the page still shows the original picture that I
deleted and replaced with the new one, even though I...
|
by: pdesai007 |
last post by:
hello,
i tried to upload an image in to server with asp and java script ( using AJAX) but it gave an error. so please give me any solution that help me to upload an image to server with java script and whithot refreshing of my page.
thank you
|
by: Kirthikaiitm |
last post by:
Hi,
I have a image button (APPLY)
On clicking apply button how to move the content from textbox to another textarea.
I wrote the code in JScript. But once i click APPLY button the form is getting refreshed and the content in test area get vanished.
How to retain the value on text area or how to avoid refreshing form on clicking image APPLY button.My button is <input type="image" src=/images/...>
Pls. help
regards,
Kirthika
|
by: mukeshrasm |
last post by:
Hi
I am printing some text on image dynamically. I am setting the font size and type dynamically and then displaying to other page. Thing is that it is not displaying the image when I click submit button but when I refresh the page Image as well as Text is dispalyed as I wanted. So why It is displaying after refreshing the page
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |