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):

Type.registerNamespace('AjaxControlToolkit');

AjaxControlToolkit.YourClassName= function(element)
{
   AjaxControlToolkit.YourClassname.initializeBase(this,[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
{
alert(alertMessage);
}

AjaxControlToolkit.YourClassName.inheritsFrom(AjaxControlToolkit.AutoCompleteBehavior);

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.