windows . forms . htmldocument不包含GetElementByID的定义

本文关键字:GetElementByID 定义 包含 forms htmldocument windows | 更新日期: 2023-09-27 17:50:38

你能解释一下为什么我收到这个错误吗?

    private void startButton_Click(object sender, EventArgs e)
    {
        HtmlElement mainNav = webBrowser1.Document.GetElementByID("home");
            mainNav.InvokeMember("click");
    }
错误1

'System.Windows.Forms.HtmlDocument' does not contain a definition for 'GetElementByID' and no extension method 'GetElementByID' accepting a first argument of type 'System.Windows.Forms.HtmlDocument' could be found (are you missing a using directive or an assembly reference?)

windows . forms . htmldocument不包含GetElementByID的定义

因为它是GetElementById,小写的'd'。

文档在:http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.getelementbyid.aspx


旁注:谷歌搜索system.windows.forms.htmldocument引导我直接检查文档,智能感知也应该能够告诉你正确的拼写。我知道有时候需要一双额外的眼睛。