2

i'm working on win form app that contains a web browser control, in the web page there is a text box field that i get it as htmlelement..

i fill it correctly with a string value, and then i want to send enter key press to submit the value in it ..

this is my code so far :

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}");

i tried invoke member, tried sendkey but none of them works..

how to do this?

Dr.Vista
  • 104
  • 2
  • 10
  • You need to `InvokeMember("submit")` on the `
    ` element, rather than on one of its child elements. Check this out: http://stackoverflow.com/q/1539685/1768303
    – noseratio Dec 01 '13 at 23:30

1 Answers1

0

From MSDN - Navigated:

// 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);
    }
}
Kyle Stoflet
  • 1,194
  • 3
  • 16
  • 27