【问题标题】:Why wont WebBrowser submit the form with this code?为什么 WebBrowser 不使用此代码提交表单?
【发布时间】:2014-01-15 20:08:07
【问题描述】:

这是代码:

public void WebBrowser wb;
public void Login(){
    wb.Navigate("http://mywebsite.com/login.php");
    wb.DocumentCompleted+=(o,e) => {
        if (wb.ReadyState != WebBrowserReadyState.Complete) return;

        var inputs = wb.Document.GetElementsByTagName("input");
        inputs["username"].SetAttribute("value",account.Username);
        inputs["password"].SetAttribute("value",account.Password);
        if (wb.Document.Forms.Count==0) return;
        wb.Document.Forms[0].InvokeMember("submit");
    };
}

WebBrowser 导航到网站,并正确填写表单。
但它不提交?

为什么?

【问题讨论】:

标签: c# browser


【解决方案1】:

你有提交按钮吗?尝试直接在其上调用点击事件。

这是请求者调用输入点击的链接,也许它会指导您。

希望能帮到你

InvokeMember("click")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-07
    • 2017-07-28
    • 1970-01-01
    相关资源
    最近更新 更多