TextBox - Browser control

B

BluDog

Hi

I have a user control that i want to display a webpage on, this page i
want to be able to toggle between the html source and the regular page
view.

The source of the page is in an text box.

At the moment, on the validation of the textbox i am writing the file
away to a temp location then loading it in the browser control.

I am thinking there must be a better way of doing this... anyone got
any suggestions:

Private Sub TextBox1_Validating(ByVal sender As System.Object,
ByVal e As System.ComponentModel.CancelEventArgs) Handles
TextBox1.Validating

Dim SaveFile As String = "C:\Temp\MyFile.htm"
Dim fileWriter As StreamWriter

Try
fileWriter = File.CreateText(SaveFile)
fileWriter.Write(TextBox1.Text)
Catch ex As IOException
MsgBox(ex.Message)

Finally
If Not fileWriter Is Nothing Then fileWriter.Close()
End Try

Browser.Navigate(SaveFile)

end sub


Thanks

Tom
 
B

BluDog

If anyone's looking in the future, here's the solution:

Private Sub TextBox1_Validating(ByVal sender As System.Object,
ByVal e As System.ComponentModel.CancelEventArgs) Handles
TextBox1.Validating

Dim oHtmlDoc As Object = Browser.Document
Dim oBody As Object = oHtmlDoc.Body
oBody.InnerHtml = TextBox1.Text

End sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top