Override javascript method in Microsoft Ajax Library

If you would like to override a method in javascript that uses the Microsoft Ajax Library (such as the control toolkit), you can do the following (with the control toolkit as the base which we are overriding):


AjaxControlToolkit.YourClassName= function(element)
  //initialize any variables here
AjaxControlToolkit.YourClassName.prototype =
_setText: function(item) //this is the function we're overriding
this._callMyNewFunction('hello there');  // we're sending an alert instead of the normal behavior
_callMyNewFunction: function(alertMessage) // my new method


AjaxControlToolkit.YourClassName.registerClass('AjaxControlToolkit.YourClassName', AjaxControlToolkit.AutoCompleteBehavior);  // second parameter is the class you're "inheriting" from

This type of behavior can be applied to any class that uses the Microsoft Ajax Library and is very useful when you need some base behavior for a control and also specific behavior for a particular implemenation.