• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 461
  • Last Modified:

Disable Web Browser Show Document Modified Prompt

I have created an HTML editor. In my application, I have a toolbar to toggle visiblity of a webbrowser control and a multiline textbox control to show HTML page and HTML source respectively.

All is working fine except let's say I input "Hello World" as input in HTML mode, then click the toggle button to switch to Text Mode, I will see the HTML source correctly. However, when I tried to toggle back to HTML mode, I will get a prompt telling me "document has been modified". How do I disable this prompt from appearing?

I shall attach the screen for the "dialog" in a short while.

Below is my code fragment.
        private void viewButton_Click(object sender, EventArgs e)
        {
            if (viewButton.Text == "HTML")
            {
                txtEditor.Text = webBrowser1.DocumentText;
                txtEditor.Visible = true;
                webBrowser1.Visible = false;
                viewButton.Text = "TEXT";
            }
            else
            {
                webBrowser1.DocumentText = txtEditor.Text;
                txtEditor.Visible = false;
                webBrowser1.Visible = true;
                viewButton.Text = "HTML";
            }
        }
0
hongjun
Asked:
hongjun
  • 4
1 Solution
 
hongjunAuthor Commented:
0
 
Bob LearnedCommented:
1) What is AllowNavigation set to?

2) Did you want to avoid navigating to a hard file?

3) I wonder if this would be a better way to write:

public void WriteToWebBrowser(){

webBrowser1.AllowNavigation = false; // this, apparently, doesnt have any singificance, i wonder why!!

if (webBrowser1.Document != null)
webBrowser1.Document.OpenNew(true);
else
webBrowser1.Navigate("about:blank");

webBrowser1.Document.Write("New Content "+(i++)+"");
}

http://geekswithblogs.net/paulwhitblog/archive/2005/12/12/62961.aspx

Bob
0
 
hongjunAuthor Commented:
I will try that tonight.

hongjun
0
 
hongjunAuthor Commented:
>> webBrowser1.AllowNavigation = false;
is sufficient for me.

hongjun
0
 
hongjunAuthor Commented:
thanks :)
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now