【发布时间】:2009-04-01 17:15:51
【问题描述】:
我有一个 Asp.net AJAX 控件,在客户端控件类中,我想为控件中的某些文本框处理 onFocus 事件。我希望所有文本框只有一个处理程序,但是在处理程序中我不知道如何获取导致焦点事件的源元素。
在我的初始化函数中,每个文本框都有以下代码:
this._onfocusFunctionDelegate = Function.createDelegate(this, this._onFocus);
$addHandler(this._textBox1, 'focus', this._onfocusFunctionDelegate); //repeated for each textbox
在 _onFocus 处理程序中,我希望能够确定哪个文本框触发了事件并为该文本框调用 select()。
_onFocus: function(evt) {
// how do I get the source element? The following doesn't work
evt.srcElement.select(); }
那么我如何确定是哪个元素触发了该事件?
【问题讨论】:
标签: asp.net ajax asp.net-ajax