Well in my windows forms application i have a simple web browser which is supposed to run a .html
file containing a css
styled registration form. It is running very well when loading the page remotely using webBrowser1.Navigate("http://www.example.com/mypage.html");
; However, When i tried to embed the .html
file [along with the css
files required] in the resources by setting the Building Action
to Embedded Resource
, the webBrowser
only navigates to the .html
file while not detecting the css
files, which result in a creepy page look.
Here are the codes i have tried so far.
The .html
file :
<link href="lang/en/compact.css" rel="stylesheet" type="text/css" />
<link href="lang/en/lang.css" rel="stylesheet" type="text/css" />
<link href="img/basics.css" rel="stylesheet" type="text/css" />
How i get the .html
file from the Embedded Resources
:
using (Stream stream = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("DummyBrowserFormImprovements.HTML." + "mypage.html"))
if (stream != null)
using (var reader = new StreamReader(stream))
{
string result = reader.ReadToEnd();
dummyBrowser1.DocumentText = result;
}
Unfortunately, The above approach only loads the .html
file without recognizing the css
files referenced in it; Hence, any detailed answer about how to embed a .html
file that uses js, css
external files in windows forms and how to load it into a webBrowser
would be very appreciated. I hope i was clear in representing my problem and thanks in advance.