Question

I would need to build a HTML document from plain text and display it in webBrowser. I was thinking of better way - I can see there is HTMLTextWriter in System.Web.UI but I cannot reference this namespace, could anyone advice? Thanks

Was it helpful?

Solution

Depending on your application requirements you could host your own browser control and build the content:

System.Windows.Forms.WebBrowser _browser = new WebBrowser();
_browser.DocumentText = "<html><head><title>My Web Page</title></head><body>Hello World!</body></html>

OTHER TIPS

Simplest way is to use plain XmlWriter (or, if you need more complex building than just writing a stream of elements, XmlDocument or XDocument) and output XHTML.

If you want to use System.Web.UI classes, you need to reference System.Web.dll from your project. I wouldn't recommend it, though, as it won't buy you much, and it is not included in the .NET Client Profile (which you might want to use in the future, especially with .NET 4).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top