[英]ASP.NET Ajax
I have a custom control that has the following prototype. 我有一个具有以下原型的自定义控件。
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();
How can i raise a post back event to the server in the _onBlur method? 如何通过_onBlur方法向服务器引发回发事件?
Cheers 干杯
Rohan 罗汉
You can use the __doPostBack method to do this, which has a signature of: 您可以使用__doPostBack方法执行此操作,该方法的签名为:
function __doPostBack(eventTarget, eventArgument)
So it would be something along the lines of: 因此,这可能与以下内容类似:
__doPostBack(this.get_element().id, 0);
Or you can optionally pass an argument along with the event if desired. 或者,您可以根据需要选择将参数与事件一起传递。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.