Search code examples
mshtmlmicrosoft.mshtml

How to access a dynamic control in mshtml created through javascript


How to access a dynamic control in mshtml created through javascript.

I have a Yes/No radio button. On selecting Yes, a textbox is dynamically created and added next to this radio button. I am able to access the radio button using HTMLDocument.getElementsByName or HTMLDocument.getElementById or HTMLDocument.all.item.

I want to access the newly created textbox. The code for creating the dynamic textbox is in javascript and I dont have any control on it.

HTMLDocument.getElementById("testId") 

returns null.


Solution

  • I had to use a new thread. If we try to use the main thread HTMLDocument does not show dynamically created controls.