943,778 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 9517
  • C# RSS
Feb 5th, 2009
0

WebBrowser Control - Saving Source

Expand Post »
Hey, im just wondering how to say the source of a webpage that is in your WebBrowser Control.

I've tried loads of methods but i am failing horribly (google isnt my friend today). Just wondering if someone could share some insight .
Similar Threads
Reputation Points: -14
Solved Threads: 1
Junior Poster in Training
FTProtocol is offline Offline
99 posts
since May 2008
Feb 6th, 2009
0

Re: WebBrowser Control - Saving Source

Hope this will be helpful

http://support.microsoft.com/kb/329014
Reputation Points: 16
Solved Threads: 18
Junior Poster
Aneesh_Argent is offline Offline
104 posts
since Dec 2008
Feb 6th, 2009
0

Re: WebBrowser Control - Saving Source

Hope this will be helpful

http://support.microsoft.com/kb/329014
i already read through all that lol and i didn't understand
Reputation Points: -14
Solved Threads: 1
Junior Poster in Training
FTProtocol is offline Offline
99 posts
since May 2008
Feb 6th, 2009
0

Re: WebBrowser Control - Saving Source

Click to Expand / Collapse  Quote originally posted by FTProtocol ...
i already read through all that lol and i didn't understand
Even I dont understand the whole article
But U just need to do this:

Include references to the Mshtml.dll file . To do this in your Visual C# .NET project, follow these steps:

1. Click Add Reference on the Project menu.
2. Click the COM tab.
3. Double-click Microsoft HTML Object Library.

On your View Source button or menu Click do this:

C# Syntax (Toggle Plain Text)
  1.  
  2. mshtml.HTMLDocument objHtmlDoc = (mshtml.HTMLDocument) webBrowser1.Document.DomDocument;
  3. /*webBrowser1 is the WebBrowser Control showing your page*/
  4. string pageSource = objHtmlDoc.documentElement.innerHTML;
  5.  
  6. /* pageSource string variable will contain the source of the page displayed in your browser control. You can dispaly it in whatever way u wish to */
Reputation Points: 16
Solved Threads: 18
Junior Poster
Aneesh_Argent is offline Offline
104 posts
since Dec 2008
Feb 24th, 2011
0
Re: WebBrowser Control - Saving Source
In case Some One Else comes across this page; This is a much easy approach for beginners:


C# Syntax (Toggle Plain Text)
  1. private void pageSourceToolStripMenuItem_Click(object sender, EventArgs e)
  2. {
  3. Form sourceForm = new Form();
  4. TextBox sourceCode = new TextBox();
  5. sourceCode.Dock = DockStyle.Fill;
  6. sourceCode.Multiline = true;
  7. sourceCode.ScrollBars = ScrollBars.Both;
  8. sourceForm.Width = 700;
  9. sourceForm.Height = 500;
  10. sourceForm.StartPosition = FormStartPosition.CenterScreen;
  11. sourceForm.ShowIcon = false;
  12. sourceForm.ShowInTaskbar = false;
  13. sourceForm.Text = "Source Code for " + WebBrowser.Url;
  14. sourceCode.Text = WebBrowser.DocumentText;
  15. sourceForm.Controls.Add(sourceCode);
  16. sourceForm.Show(this);
  17. sourceCode.ReadOnly = true;
  18. }
Reputation Points: 10
Solved Threads: 5
Light Poster
saad749 is offline Offline
43 posts
since Sep 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Text file not containing all lines written by StreamWriter
Next Thread in C# Forum Timeline: Use of new in delegate





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC