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,
:)

If you can convert text to html tags you can save these tags into text file with extension htm\html!

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.:)

You can save it into file .html\htm then call

webbrowser.Navigate(htmlFilePath)

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?

You save it into temp file on local HDD, then preview it... No great memory consumption.

ok i will try it, thanks for taking time to answer me! ;)

You're welcome, if this thread answered, please mark it as solved.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.