I am working on a basic web page editor using mshtml.dll and a WebBrowser control. I want to switch between "design view" and "code view" - the latter showing the HTML tags etc. I can copy the HTML to a textbox to produce the code view and it works fine. Copying the HTML back to the WebBrowser control (allowing the user to make edits to the HTML tags and then show those changes in "design view") is not working properly. After a few clicks between design view and code view, the contents of the WebBrowser control start being duplicated. One line of text becomes two, then four, then eight etc.
Here is some of my code.
Initialisation:
Design view - code view switching:
I guess I need to clear something before writing txtHTML.Text into the WebBrowser control, but I can't seem to find what it is.
Any help would be much appreciated.
Here is some of my code.
Initialisation:
Code:
Imports mshtml
Dim Mdoc As IHTMLDocument2
wb1.DocumentText = "<html><body></body></html>"
Mdoc = wb1.Document.DomDocument
Mdoc.designMode = "On"Code:
If optEditor.Checked Then
wb1.Visible = True
txtHTML.Visible = False
wb1.Document.Write(txtHTML.Text)
Else
wb1.Visible = False
txtHTML.Visible = True
txtHTML.Text = wb1.DocumentText
End IfAny help would be much appreciated.