Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 是否不能使用HTMLElementCollection单击“提交”按钮?_C# - Fatal编程技术网

C# 是否不能使用HTMLElementCollection单击“提交”按钮?

C# 是否不能使用HTMLElementCollection单击“提交”按钮?,c#,C#,请帮忙 我认为您的查询永远不会得到提交按钮。您需要将其更改为: theElementCollection = webBrowser1.Document.GetElementsByTagName("input"); foreach (HtmlElement curElement in theElementCollection) { if (curElement.GetAttribute("id").Equals("submit")) {

请帮忙

我认为您的查询永远不会得到提交按钮。您需要将其更改为:

theElementCollection = 
            webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement curElement in theElementCollection)
{
        if (curElement.GetAttribute("id").Equals("submit"))
        {
           curElement.InvokeMember("click");                   
        }
}


对于您在评论中提到的问题,您可能应该使用事件来单击按钮。

是否可以添加docSubmit()代码?格式化您的代码和代码对于获得一个好的答案有很大帮助。不,我在另一个网站上单击按钮时使用了相同的代码,并且成功了??它在url加载到webbrowser之前按了提交按钮。它给出了一个错误,即“此页面上的脚本出现了错误”它按下了提交按钮,但什么也不做……plzz help?@user2233501我更新了我的答案。将您的代码放入
DocumentCompleted
Event我这样做了,但它不起作用,在button1_单击中,我正在运行上述webBrowser1.DocumentCompleted+=新的WebBrowserDocumentCompletedEventHandler(button1_单击);
theElementCollection = 
            webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement curElement in theElementCollection)
{
        if (curElement.GetAttribute("id").Equals("submit"))
        {
           curElement.InvokeMember("click");                   
        }
}
theElementCollection = 
            webBrowser1.Document.GetElementsByTagName("button");