Thursday, January 10, 2008

How to monitor text changes in an input box on a web page

I was assigned a task to implement something like Autocomplete control in ASP.NET Ajax Control Tool Kit with JavaScript. The only difference is that instead of displaying a drop drown list like what Autocomplete does, I need to display more rich content.

It took me a while to figure out how to monitor the input text changes in a text box. I created kyepress and mousedown and various other event handlers to start the process to monitor the input text box. It worked in some cases, but failed in others.

In the end, I have to take a look into the source code that implemented Autocomplete control released with Ajax Contrl Took Kit by Microsoft. The correct answer is to intercept focus, blur, and keydown events. In the past, it would not be possible because all the software is not open-sourced. The only solution is to read documentation and use trial and error approach.

No comments: