views:

255

answers:

2

I am currently working on a project where I am using a WebBrowser control as an editor. I have design mode turned on and it seems to be working. The issue im having is when I try to save the Document and load another it pops up the "This document has been modified." message. What I am trying to do is as simple as this

if (frontPage)
{
    frontPage = false;
    frontContent = webEditor.DocumentText;
    webEditor.DocumentText = backContent;
}
else
{
    frontPage = true;
    backContent = webEditor.DocumentText;
    webEditor.DocumentText = frontContent;
}

Like I said everytime I enter some text and run this code it just pops up a message saying its been modified and asks if I want to save. How can I get around this?

A: 

Try this webEditor.ScriptErrorsSuppressed = true;

Make sure you have disabled Script Debugging in IE in case you've turned it on.

Nissan Fan
+1  A: 

The way Windows Forms load a document stream (used by the DocumentText property) is to navigate away to about:blank, which triggers the document modified message, then load the stream in its DocumentComplete event handler.

Since you already have a document, you can skip the navigation and load the stream into the existing document directly via its IPersistStreamInit interface like Windows Forms does in its DocumentComplete event handler.

Sheng Jiang 蒋晟