How to dynamically generate HTML code using .NET’s WebBrowser or mshtml.HTMLDocument?

Here is a beautiful way to get this work done without stressing yourself looking for so many solutions that may not even work at the end of the day.It may not always be possible to determine when the page has finished rendering with 100% probability. Some pages are quite complex and use continuous AJAX updates.