remember, you have to wait until the contents of the webpage have been loaded in order for you to view the source/code of that site otherwise you will get nothing, as you currently maybe experiencing.
Select the webbrowser control in designer view. View the events (lightning icon in the properties window) and double click "documentCompleted" to create the document completed event so it will automatically "fire" when the page has been loaded.
what doesnt work you need to be specific :-) Any errors if not then what doesnt work
what are you trying to do View the source code of the current page in the webbrowser control if so, you will need to store the source code in some way such as save it to disk or something. However the DocumentText property of the webbrowser control contains the entire source code of the page you are viewing
Example, saving it to a simple file on your computer.
Dim theWriter as new System.IO.StreamWriter(Application.StartupPath & "\sourceCodeWebPage.txt")
of course replace the name of the control for your webbrowser correctly. This will save the source code of the page to disk in the same directory as your application
you can right click the webbrowser then go to view source code as you do in IE. programmatically the source code for the entire page is in the DocumentText property.
Me.theWebBrowserControl.DocumentText
the document text holds the entire page.
further more you can access specific elements/get specific elements etc... via the Document property. It contains things like GetElementById, or access Forms by index to get contents of that form and so on.
View source code!!!
2ndrnd02
ok.
1) did you navigate to a webpage first in the webbrowser
Me.theWebBrowserControl.Navigate("http://www.microsoft.com")
2) did you do this to display the code in a textbox after the page was loaded
Me.theTextBox.Text = Me.theWebBrowserControl.DocumentText
remember, you have to wait until the contents of the webpage have been loaded in order for you to view the source/code of that site otherwise you will get nothing, as you currently maybe experiencing.
Select the webbrowser control in designer view. View the events (lightning icon in the properties window) and double click "documentCompleted" to create the document completed event so it will automatically "fire" when the page has been loaded.
in this event, do this:
Me.theTextBox.Text = Me.theWebBrowserControl.DocumentText
what happens now
snakeoooooo
eldiener
im am not so goed in english.
but am gonna try:
i have a Webbrowser (webbrowser1)
and a textbox (textbox1)
now i just want the source code of the current page of webbrowser1
i dit what you say but textbox1 is just empty!
Wildert
It works!!!!!!!!!
thanks!
Wolfgang Kamir
what doesnt work you need to be specific :-) Any errors if not then what doesnt work
what are you trying to do View the source code of the current page in the webbrowser control if so, you will need to store the source code in some way such as save it to disk or something. However the DocumentText property of the webbrowser control contains the entire source code of the page you are viewing
Example, saving it to a simple file on your computer.
Dim theWriter as new System.IO.StreamWriter(Application.StartupPath & "\sourceCodeWebPage.txt")
theWriter.Write(Me.theWebBrowserControl.DocumentText)
theWriter.Close()
of course replace the name of the control for your webbrowser correctly. This will save the source code of the page to disk in the same directory as your application
Ultrawhack
Daniel TIZON
you can right click the webbrowser then go to view source code as you do in IE. programmatically the source code for the entire page is in the DocumentText property.
Me.theWebBrowserControl.DocumentText
the document text holds the entire page.
further more you can access specific elements/get specific elements etc... via the Document property. It contains things like GetElementById, or access Forms by index to get contents of that form and so on.
http://msdn2.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx