I want to have a webBrowser open a HTML string. This is what I got so far for opening the HTML string in a webBrowser:
public void show()
{
routelistBrowser.ScriptErrorsSuppressed = true;
reisOpties = fakeLijst(gekozenTijd);
RouteListPanel rlp = new RouteListPanel();
rlp.Session = new Dictionary<string, object>();
rlp.Session["reisOpties"] = reisOpties;
rlp.Initialize();
Console.WriteLine(rlp.TransformText());
DisplayHtml(rlp.TransformText());
}
private void DisplayHtml(string html)
{
routelistBrowser.Navigate("");
HtmlDocument doc = routelistBrowser.Document.OpenNew(true);
doc.Write(html);
routelistBrowser.Refresh();
Console.WriteLine(html);
}
My problem is that my webBrowser won't load this HTML string. I am not sure what I am doing wrong. I have added the webBrowser in a User Control and added that User Control in the Main Form. The webBrowser will show, but will not load the HTML string. Output Console (HTML string):
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=11" />
<title></title>
<style type="text/css">
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<div id ="container" class="container">
<ul style="list-style-type:none;">
<li>
<div>
<h1>17:54 --> 18:13</h1><h3>Totale tijd: 0:19
Aantaloverstappen: 0x Perron: 1a</h3>
<h3>NS - Intercity</h3>
</div>
</li>
</ul>
<ul style="list-style-type:none;">
<li>
<div>
<h1>18:00 --> 18:19</h1><h3>Totale tijd: 0:19
Aantaloverstappen: 0x Perron: 1a</h3>
<h3>NS - Intercity</h3>
</div>
</li>
</ul>
<ul style="list-style-type:none;">
<li>
<div>
<h1>18:06 --> 18:25</h1><h3>Totale tijd: 0:19
Aantaloverstappen: 0x Perron: 1a</h3>
<h3>NS - Intercity</h3>
</div>
</li>
</ul>
<ul style="list-style-type:none;">
<li>
<div>
<h1>18:12 --> 18:31</h1><h3>Totale tijd: 0:19
Aantaloverstappen: 0x Perron: 1a</h3>
<h3>NS - Intercity</h3>
</div>
</li>
</ul>
<ul style="list-style-type:none;">
<li>
<div>
<h1>18:18 --> 18:37</h1><h3>Totale tijd: 0:19
Aantaloverstappen: 0x Perron: 1a</h3>
<h3>NS - Intercity</h3>
</div>
</li>
</ul>
<ul style="list-style-type:none;">
<li>
<div>
<h1>18:24 --> 18:43</h1><h3>Totale tijd: 0:19
Aantaloverstappen: 0x Perron: 1a</h3>
<h3>NS - Intercity</h3>
</div>
</li>
</ul>
<ul style="list-style-type:none;">
<li>
<div>
<h1>18:30 --> 18:49</h1><h3>Totale tijd: 0:19
Aantaloverstappen: 0x Perron: 1a</h3>
<h3>NS - Intercity</h3>
</div>
</li>
</ul>
</div>
</body>
</html>