0

When I try to SetAttribute on <Input> element, the text doesn't invoke onkeypress JS function.
What should I do? I was thinking about using "sendkeys". But, it's not a good solution to handle with threads.

onkeypress="return filtraPassa(this, event, 'THIS_VAR_CHANGES_EVERYPAGELOAD');">
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Eric Otani
  • 13
  • 2

1 Answers1

0

If you want to configure a .NET handler for the keypress event, you should take a look at DOM Events.

The following sample code demonstrates how to add DOM event listener to the element:

DOMEventHandler domEvent = delegate(object sender, DOMEventArgs e)
{
     DOMEventType eventType = e.Type;
     Console.Out.WriteLine("handled event = " + eventType);
};

element.AddEventListener(DOMEventType.OnKeyPress, domEvent, false);

In addition, you need to take into account that modifying the element attribute may have no effect on its property: What is the difference between properties and attributes in HTML?

Anna Dolbina
  • 1
  • 1
  • 8
  • 9