1

I have a database which has stored HTML code sources for different articles which are not in similar HTML design pattern. I want to display these codes in windows form application control e.g WebBrowser control so that it can be displayed in its original HTMLdesign style as if in the browser.But i hope if this process doesn't include creating html files on hard drive to read from it and i wish if there is a way to make the WebBrowser control navigate from objects created in the memory not created on hard drive .. For example i wish if the code could be like this :

HTMLFile myfile = new HTML File (htmlcode);
webbrowser1.Navigate(myfile);
EgyEast
  • 1,542
  • 6
  • 28
  • 44
  • Just be careful if you are letting users put html into your database. You don't want to open yourself up to scripting attacks. – captncraig Mar 19 '11 at 17:56

1 Answers1

3

You should be able to do this using the DocumentText property of the WebBrowser control.

For example:

webBrowser1.DocumentText = "<html><body><h1>This is a test</h1></body></html>";

See this post for more info: C# WebBrowser HTML with references to scripts and images

Community
  • 1
  • 1
rsbarro
  • 27,021
  • 9
  • 71
  • 75