ASP.NET Ajax

时间秒杀一切 提交于 2019-12-11 03:29:46

问题


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?

Cheers

Rohan


回答1:


You can use the __doPostBack method to do this, which has a signature of:

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.



来源:https://stackoverflow.com/questions/300052/asp-net-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!