Roh*_*est 2 javascript asp.net-ajax
我有一个自定义控件,具有以下原型.
Type.registerNamespace('Demo');
Demo.CustomTextBox = function(element) {
Demo.CustomTextBox.initializeBase(this, [element]);
}
Demo.CustomTextBox.prototype = {
initialize: function() {
Demo.CustomTextBox.callBaseMethod(this, 'initialize');
this._onblurHandler = Function.createDelegate(this, this._onBlur);
$addHandlers(this.get_element(),
{
'blur': this._onBlur
},
this);
},
dispose: function() {
$clearHandlers(this.get_element());
Demo.CustomTextBox.callBaseMethod(this, 'dispose');
},
_onBlur: function(e) {
if (this.get_element() && !this.get_element().disabled) {
alert(this.get_element().value);
}
}
}
Demo.CustomTextBox.registerClass('Demo.CustomTextBox', Sys.UI.Control);
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
Run Code Online (Sandbox Code Playgroud)
如何在_onBlur方法中将回发事件提升到服务器?
干杯
罗汉
您可以使用__doPostBack方法执行此操作,该方法具有以下签名:
function __doPostBack(eventTarget, eventArgument)
Run Code Online (Sandbox Code Playgroud)
所以这将是:
__doPostBack(this.get_element().id, 0);
Run Code Online (Sandbox Code Playgroud)
或者,如果需要,您可以选择将参数与事件一起传递.