E
esw
Hi,
I am using the WebBrowser control in a winform app (.NET 2.0, WinXP
SP2). I am loading a local file which contains Javascript which
dynamically modifies the layout of the page when it loads. When I set
the URL to this file and then call Print(), it prints correctly
(Javascript is executed). When I call Print() in DocumentCompleted, it
prints incorrectly (as though the Javascript is not executed) even
though the page displays correctly in the embedded browser. I have
tried testing for IsBusy and WebBrowserReadyState.Complete but it does
not make a difference. Does anyone understand why this is happening? Am
a forgetting to set something? I am wondering if its a security
issue... that in DocumentCompleted the document is perceived as
belonging to the wrong zone.
// prints correctly
this.webBrowser2.Url = new Uri(@"C:\myfile.html");
this.webBrowser2.Print();
// prints incorrectly
private void btnPrint_Click(object sender, EventArgs e)
{
this.webBrowser2.DocumentCompleted += new
WebBrowserDocumentCompletedEventHandler(webBrowser2_DocumentCompleted);
this.webBrowser2.Url = new Uri(@"C:\myfile.html");
}
void webBrowser2_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
if (this.webBrowser2 != null)
{
this.webBrowser2.Print();
}
}
Thanks!
- esw
I am using the WebBrowser control in a winform app (.NET 2.0, WinXP
SP2). I am loading a local file which contains Javascript which
dynamically modifies the layout of the page when it loads. When I set
the URL to this file and then call Print(), it prints correctly
(Javascript is executed). When I call Print() in DocumentCompleted, it
prints incorrectly (as though the Javascript is not executed) even
though the page displays correctly in the embedded browser. I have
tried testing for IsBusy and WebBrowserReadyState.Complete but it does
not make a difference. Does anyone understand why this is happening? Am
a forgetting to set something? I am wondering if its a security
issue... that in DocumentCompleted the document is perceived as
belonging to the wrong zone.
// prints correctly
this.webBrowser2.Url = new Uri(@"C:\myfile.html");
this.webBrowser2.Print();
// prints incorrectly
private void btnPrint_Click(object sender, EventArgs e)
{
this.webBrowser2.DocumentCompleted += new
WebBrowserDocumentCompletedEventHandler(webBrowser2_DocumentCompleted);
this.webBrowser2.Url = new Uri(@"C:\myfile.html");
}
void webBrowser2_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
if (this.webBrowser2 != null)
{
this.webBrowser2.Print();
}
}
Thanks!
- esw