Take a Textbox as an example to use JavaScript to determine whether it gets the focus.
In fact, it is very simple. The normal thinking is divided into two ways:
When the text box is the server control, we can simply think of using: if (textbox1.focused) to judge, and use Textbox1.attributes.add ('Onfocus', 'method to execute'); method. Of course, the server's control can also be operated using JS. However, it is necessary to remind that the ID of the server is likely to be different from the ID of the actual client, so you need to pay attention when using GetelementByID <%= Textbox1.clientid%> ').
When the text box is the server, you can use the document.activeElement.id and Textbox1 to know whether the textbox1 is the focus. For example: if (documeactiveElement == DOCUMENT.FORM1.ElementName) {}.