I know that this is a common question but I couldnt find an answer for my problem. I am currently working on a HTML editor. With one button click you can change from the webbrowser view to the textview. If I press the button again the webbrowser will be displayed again with the HTML code. But I can also change the code manually in text mode and if I do that the code will be displayed wrong. For example: If I write something like this:
Ö Ä Ü
and I change something it will show this:
Ö Ä Ü
I already tried this:
byte[] bytes = Encoding.Default.GetBytes(mytextbox.Text);
string htmlcode = Encoding.UTF8.GetString(bytes);
and this:
HttpUtility.HtmlDecode
but that didnt work. I hope you can help me.
EDIT:
I have a WPF WebBrowser where I can edit my code with mshtml. If I write something like this:
Ö Ä U
and I change to the text view with this code:
mytextbox.Text = doc.body.outerHTML;
the HTML code shown in the textbox:
<BODY>Ö Ä Ü</BODY>
the textbox is ReadOnly if you want to edit this you need to press another button. If I edit the text and change to the browserview again currently with this code:
if (myWebBrowser != null)
{
myWebBrowser.Dispose();
browsergrid.Children.Remove(myWebBrowser);
}
if (doc != null)
{
doc.clear();
}
myWebBrowser = new WebBrowser();
browsergrid.Children.Add(myWebBrowser);
myWebBrowser.NavigateToString(mytextbox.Text);
doc = myWebBrowser.Document as HTMLDocument;
doc.designMode = "On";
the Browser displays this:
Ö Ä Ü