how to load html code in web browser in c 23 vs

Solutions on MaxInterview for how to load html code in web browser in c 23 vs by the best coders in the world

showing results for - "how to load html code in web browser in c 23 vs"
Anna
06 Sep 2016
1    static public void SetWebBrowserHtml(WebBrowser Browser, string HtmlText)
2    {
3        if (Browser != null)
4        {
5            if (string.IsNullOrWhiteSpace(HtmlText))
6            {
7                // Putting a div inside body forces control to use div instead of P (paragraph)
8                // when the user presses the enter button
9                HtmlText = 
10                        @"<html>
11                    <head>
12                    <meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"" />
13                    </head>
14                      <div></div>
15                    <body>
16                    </body>
17                    </html>";
18            }
19
20            if (Browser.Document == null)
21            {
22                Browser.Navigate("about:blank");
23
24                //Wait for document to finish loading
25                while (Browser.ReadyState != WebBrowserReadyState.Complete)
26                {
27                    Application.DoEvents();
28                    System.Threading.Thread.Sleep(5);
29                }
30            }
31
32            // Write html code
33            dynamic Doc = Browser.Document.DomDocument;
34            Doc.open();
35            Doc.write(HtmlText);
36            Doc.close();
37
38
39            // Add scripts here 
40            /*  
41            dynamic Doc = Document.DomDocument;
42            dynamic Script = Doc.getElementById("MyScriptFunctions");
43            if (Script == null)
44            {
45                Script = Doc.createElement("script");
46                Script.id = "MyScriptFunctions";
47                Script.text = JavascriptFunctionsSourcecode;
48                Doc.appendChild(Script);
49            }                 
50            */
51
52
53
54            // Enable contentEditable   
55            /*  
56            if (Browser.Document.Body != null)
57            {
58                if (Browser.Version.Major >= 9)
59                    Browser.Document.Body.SetAttribute("contentEditable", "true");
60            }             
61             */
62
63            // Attach event handlers
64            // Browser.Document.AttachEventHandler("onkeyup", BrowserKeyUp);
65            // Browser.Document.AttachEventHandler("onkeypress", BrowserKeyPress);
66            // etc...
67        }
68    }        
69
Josefina
20 Jul 2016
1//Create the WebBrowser control
2WebBrowser wb = new WebBrowser();
3//Add a new event to process document when download is completed   
4wb.DocumentCompleted +=
5    new WebBrowserDocumentCompletedEventHandler(DisplayText);
6//Download the webpage
7wb.Url = urlPath;
Maxime
03 Feb 2018
1private void DisplayText(object sender, WebBrowserDocumentCompletedEventArgs e)
2{
3WebBrowser wb = (WebBrowser)sender;
4wb.Document.ExecCommand("SelectAll", false, null);
5wb.Document.ExecCommand("Copy", false, null);
6textResultsBox.Text = CleanText(Clipboard.GetText());
7}