I have an Asp.net AJAX control and in client control class I want to handle the onFocus event for some textboxes in my control. I would like to have only one handler for all the textboxes, however in the handler I don’t know how to get the source element that caused the focus event.
In my initialize function I will have the following code for each text box:
this._onfocusFunctionDelegate = Function.createDelegate(this, this._onFocus); $addHandler(this._textBox1, 'focus', this._onfocusFunctionDelegate); //repeated for each textbox
in the _onFocus handler I want to be able to determine which textbox fired the event and call select() for that textbox.
_onFocus: function(evt) { // how do I get the source element? The following doesn't work evt.srcElement.select(); }
So how do I figure out what element fired the event?
I was able to get this working by accessing the event object and using the target property. On MSDN I was only able to find references to srcElemnt, but found target mentioned much more on the web. Trying target solved the issue. If anyone can find documentation backing this up I would appreciate a pointer to it.