I am going to make a VB.Net project where it is necessary to display HTML pages (like in Internet Explorer) which should be loaded from Web Server (IIS). Is it possible and how ?
Printable View
I am going to make a VB.Net project where it is necessary to display HTML pages (like in Internet Explorer) which should be loaded from Web Server (IIS). Is it possible and how ?
I've seen a friend of mine using the COM Microsoft Web Browser to display HTML file from within VB.NET app.
Right-click on your toolbox and choose Customize Toolbox option from the pop-up menu. Then choose Microsoft Web Browser control from the COM Component tab.
Now you should have an icon on your toolbox that is called Microsoft Web Browser and in your REFERENCES folder (project explorer), you'll have AxSHDocVw (the DLL for the web browser).
Just drag the Web Browser icon on your form and use the available methods to load up HTML file.
-Cool Bizs
i want to do the same thing, but i dont want to display a htlm file, i want to more or less display a string in some kind of control that will parse the string's html tags and display correctly, kinda like a richtext box with text set to "<b>this is bold</b>" but displays "this is bold" in a bold font so you don't see the tags etc.
is there something out there to do this or do i need to write my own parser????
ipsteal
Yes, the web browser control supports what you've asked for. For a simple example, do what coolbiz has instructed and then create a simple html page on to ur desktop.
AxWebBrowser1.Navigate("c:\myhtm.htm")
or
AxWebBrowser1.Navigate("http://...")
Once u got this proof of concept, u know what to do next
yeah, that works, but that is still for the html file
i dont want to do:
AxWebBrowser1.Navigate("http://www.google.com")
i want something with the concept
AxWebBrowser1.Source = "<html><title>My Page</title><body>Hello everyone!<br><br><b>BOLD</b></body></html>"
so that i dont have to use files
i suppose i could just create a temp file and dump the source i want to display into it, but that would be not very efficient :(
You can still achieve your goal but at the expense of INTEROPing with COM/ActiveX components. Hopefully M$ will come up with .NET web browser component soon.
Any way, I tested this with a windows app project that included "Microsoft Web Browser Control (ShDocVw.dll)" from the TOOLBOX and "Micorosft HTML Object Library (MSHTML.TLB)" from the REFERENCES folder.
Once you drag the Web Browser control onto the form, add a button (by default Button1). Then add this code in:
Good Luck,Code:Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim htmlDoc As mshtml.HTMLDocumentClass = DirectCast(AxWebBrowser1.Document, mshtml.HTMLDocumentClass)
With htmlDoc
.clear()
.body.innerHTML = "<b>This is a test</b>"
End With
End Sub
-Cool Bizs
most excellent!
2 points for you :)
thanks again
ipsteal
coolbiz or anyone....
Why do I get the err below for the code Sub Button2_Click:
An unhandled exception of type 'System.NullReferenceException' occurred in HTMLDirectCaster.exe
Additional information: Object reference not set to an instance of an object.
Thanks
Nevermind... I got it.
It's because the page has a delay which causes the intiation to delay.
Regards