Rene Braun

Rene Braun

  • NA
  • 1
  • 1.3k

Simulate ENTER-KEY in HTML-Form in C#?

Jun 12 2015 9:11 PM
I want to start off with a picture:
 
 
 

Lets assume i do have that form in Visual C#.What i want to accomplish now is that i simulate a "PRESSED ENTER KEY" on my keyboard when im in the HTML-ELEMENT "textbox_name". I already tried it with SendKeys.Send("{ENTER}"); which has no effect. I successfully wrote a value into the Box like this:

public void putByClass(String className, String value)
{
HtmlElementCollection links = webBrowser1.Document.All;

foreach (HtmlElement link in links)
{
if (link.GetAttribute("className") == className)
{
link.SetAttribute("value", value);
}
}
}

putByClass("textbox_name_class", "John");

After the line link.SetAttribute("value", value); which puts the name "John" into the Box i want to press the "Enter"-Button on the Keyboard. Thank you very much in advance.


Answers (1)