Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the WinForms/Console Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 1st, 2010, 10:18 PM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default clear cache for WebBrowser

Assume I have a WebBrowser control called webBrowser1, and I would like to use it to display an image, which changes from time to time. I thought that I could show the most up-to-date image by calling the following line:
webBrowser1.DocumentText = "<img src='foo' width='100%' height='100%'>";
But that didn't work, and looked like WebBrowser kept a cached image.

I tried Refresh() and Refresh(WebBrowserRefreshOption.Complete), and none of those worked either.

I can make it work by set url to foo and then call Refresh(). But that won't work for every situation, for example when I have multiple images on the page.

Last edited by PeterPeiGuo; March 2nd, 2010 at 01:44 PM..
 
Old March 2nd, 2010, 02:28 AM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

Figured out. One solution is to do the following:

import this:
[DllImport("wininet.dll")]
private static extern long DeleteUrlCacheEntry(string lpszUrlName);

and call it
DeleteURLCacheEntry(image_url);





Similar Threads
Thread Thread Starter Forum Replies Last Post
Webbrowser control mussie C# 2005 1 March 2nd, 2010 01:10 PM
Webbrowser content vincentvdm BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 0 January 12th, 2008 10:52 AM
Some doubts about WebBrowser Control Xc0d C# 2005 4 November 5th, 2007 11:31 AM
webbrowser question pascali70 C# 2005 0 December 29th, 2006 10:11 AM
WebBrowser control atingoldy Beginning VB 6 1 June 16th, 2003 06:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.