Amazon.com Widgets

Bryan C. Fleming

asp.net c# Image Control doesn’t update (fix)

Filed under: Uncategorized — Bryan C. Fleming @ 8:04 am

When writing asp.net c# pages, you might notice that the image control will not refresh when pointing to an image on the server. The control itself will refresh the image if the file name changes, but if the picture changes (and not the filename) then you’ll always be stuck with the same old image.

I found a fix for this and wanted to post it (since it’s not so easy to find).

By passing a dynamic parameter to the back of the image URL, you’ll trick the control into thinking the filename has changed. Magically the control will start working as expected.

So if you code was:

oImage.ImageURL = “/images/picture.jpg”;

change it to:

oImage.ImageURL = “/images/picture.jpg?” + System.DateTime.Now.ToString();

Useful Links:

Stand out from the rest with quality shirts and ties.

Like this article? Subscribe to my RSS Feed .

WordPress database error: [Can't open file: 'wp_comments.MYI'. (errno: 130)]
SELECT * FROM wp_comments WHERE comment_post_ID = '15' AND comment_approved = '1' ORDER BY comment_date

Leave a Reply

 
Free Link Exchange - Directory - SQL 2005 Web Hosting