C# 如何在web浏览器控件中将按键发送到htmlelement

C# 如何在web浏览器控件中将按键发送到htmlelement,c#,webbrowser-control,C#,Webbrowser Control,我正在开发win form应用程序,它包含一个web浏览器控件,在网页中有 一个文本框字段,我将其作为htmlelement获取 我用一个字符串值正确地填充它,然后我想发送回车键来提交 其中的价值 这是我目前的代码: HtmlDocument hd = wbr.Document;//wbr is web browser control HtmlElement he = hd.GetElementById("response_field"); he.SetAttribute("value", an

我正在开发win form应用程序,它包含一个web浏览器控件,在网页中有 一个文本框字段,我将其作为htmlelement获取

我用一个字符串值正确地填充它,然后我想发送回车键来提交 其中的价值

这是我目前的代码:

HtmlDocument hd = wbr.Document;//wbr is web browser control
HtmlElement he = hd.GetElementById("response_field");
he.SetAttribute("value", ans);//filled correctly 
wbr.Select();
he.Focus();
he.InvokeMember("submit");
SendKeys.Send("{ENTER}");
我尝试调用成员,尝试sendkey,但都不起作用

如何做到这一点?

来自:


您需要在
元素上调用成员(“提交”),而不是在其子元素上。看看这个:
// Navigates to the URL in the address box when 
// the ENTER key is pressed while the ToolStripTextBox has focus.
private void toolStripTextBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        Navigate(toolStripTextBox1.Text);
    }
}