Archive for the ‘c#’ Category

Setting HTML for WebBrowser in C#

Today I tryed to insert HTML for WebBorwser in C#. I thought it’s a simple task. But when I tryed to use DocumentText property I got “<HTML></HTML>”. Then I tryed Document.Write("...") and I got that Document is null. After these tries I started to find out the easiest way to fill the WebBrowser with HTML without writing to disk and navigating the written file. Here is my code:

WebBrowser browser = new WebBrowser();
 
browser.Navigate("about:blank");
browser.Document.Write("<html><body>...</body></html>");

When the WebBrowser has been made, the Document object is null. So, we should call Navigate() method to get Document available.

If You have Your way to fill the WebBrowser with HTML I’m expecting for Your comments :)

Search
Categories
Archives

You are currently browsing the archives for the c# category.

Other: