Hello All, i have an aplication to make that converts a rtf text into html and then the html code must be shown into a web browser. What can't I do is to convert the HTML Code into a html website. To make myself more clear, what i want from you guys to help me is how can i take the generated HTML code and show it to a browser without having to create an HTML File and then run the html file....


Thanks in Advance,
:)

Do you want to show HTML in the browser application or with .NET's web browser control?

In the first case, you'll have to save HTML code to a file. In the latter case i.e. your VB.NET application shows the page with web browser control, you do not have to create a file:

Imports System.Text
Imports System.IO

Dim MemStream As MemoryStream
Dim ByteArr() As Byte
Dim Page As String
Page = ""
Page = Page & "<html>"
Page = Page & "<head>"
Page = Page & "<title>MemoryStream</title>"
Page = Page & "</head>"
Page = Page & "<body>"
Page = Page & "Hello Net!"
Page = Page & "</body>"
Page = Page & "<html>"
ByteArr = Encoding.Default.GetBytes(Page)
MemStream = New MemoryStream(ByteArr)
WebBrowser1.DocumentStream = MemStream

im trying to show the generated html code in the .NET web browser control, but it stucks

here's the code im trying to use:

wbrPreview.DocumentText = txtHTML.Text

Where the wbrPreview is the .NET Web Browser and the txtHTML.text is the textbox wich contains the HMTL.:)

but wouldnt that take a lot of memory that every time i want to preview a HTML page to save the code and then run it?

Hi Alexpap! See my #3 post how to use webbrowser control.
Your code should be following:

Imports System.Text
Imports System.IO

Dim MemStream As MemoryStream
Dim ByteArr() As Byte
ByteArr = Encoding.Default.GetBytes(txtHTML.Text)
MemStream = New MemoryStream(ByteArr)
wbrPreview.DocumentStream = MemStream

This works for me.

This article has been dead for over six months. Start a new discussion instead.