TextBox - Browser control

  • Thread starter Thread starter BluDog
  • Start date Start date
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
 
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
 
Back
Top