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

i already read through all that lol and i didn't understand :(

Even I dont understand the whole article:icon_rolleyes:
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:

mshtml.HTMLDocument objHtmlDoc = (mshtml.HTMLDocument) webBrowser1.Document.DomDocument;
/*webBrowser1 is the WebBrowser Control showing your page*/
string pageSource = objHtmlDoc.documentElement.innerHTML;

/* 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 */

In case Some One Else comes across this page; This is a much easy approach for beginners:

private void pageSourceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form sourceForm = new Form();
            TextBox sourceCode = new TextBox();
            sourceCode.Dock = DockStyle.Fill;
            sourceCode.Multiline = true;
            sourceCode.ScrollBars = ScrollBars.Both;
            sourceForm.Width = 700;
            sourceForm.Height = 500;
            sourceForm.StartPosition = FormStartPosition.CenterScreen;
            sourceForm.ShowIcon = false;
            sourceForm.ShowInTaskbar = false;
            sourceForm.Text = "Source Code for " + WebBrowser.Url;
            sourceCode.Text = WebBrowser.DocumentText;
            sourceForm.Controls.Add(sourceCode);
            sourceForm.Show(this);
            sourceCode.ReadOnly = true;
        }
This article has been dead for over six months. Start a new discussion instead.