Hi,
I'm trying to make screenshots of web pages from an ASP.net 2.0 page. One
trick I found is to use the Webbrowser control which works pretty fine.
however, I stumbled upon that website (
http://taxi535.blogspot.com/) where
there is a annoying javascript when we quit the page. This Javascript makes
my asp.net page using the WebBrowser control to loop infinitely. How can I
get rid of that?
// Load the webpage into a WebBrowser control
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnabled = false;
wb.ScriptErrorsSuppressed = true;
wb.Navigate("http://taxi535.blogspot.com/");
while (wb.ReadyState != WebBrowserReadyState.Complete)
{
System.Windows.Forms.Application.DoEvents();
}
// Set the size of the WebBrowser control
wb.Width = 1024;
wb.Height = 768;
// Get a Bitmap representation of the webpage as it's rendered in the
WebBrowser control
Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
wb.Dispose();
I found that I could use the Silent property, but it's not working with
ASP.NET 2.0 and I get this error :
System.Windows.Forms.WebBrowser does not contain a definition for Silent
I tried to limit the while, but it's not working either.
So I don't know what else to do to disable javascript. I'm thinking of
switching to another method to get that screenshot. Any trick or idea would
be appreciated.
thanks!
Stephane