First at all, you can't get MicrosoftAjax client object by jQuery selector. So this syntax var behavior = $('#ZipcodeBehavior');
doesn't make sense. Use $find("BehaviorID")
instead.
To add disabling capability to AutoCompleteExtender add reference on this script to ScriptManager
control:
Sys.Extended.UI.AutoCompleteBehavior.prototype.set_enabled = function (value) {
try {
$removeHandler(this.get_element(), "keydown", this._keyDownHandler);
} catch (error) {} //just escape error if handler already removed
this._timer.set_enabled( !! value);
if (value) {
this._keyDownHandler = Function.createDelegate(this, this._onKeyDown);
} else {
this._keyDownHandler = Function.createDelegate(this, function () {});
}
$addHandler(this.get_element(), "keydown", this._keyDownHandler);
};
After that you may to disabled/enable extender with this code:
$('#<%= ddlCountries.ClientID %>').change(function () {
var chosenCountry = $(this).val();
$find("ZipcodeBehavior").set_enabled(chosenCountry == "CH");
});
BTW, with Enabled="false"
property specified in markup I'm afraid you shouldn't enable extender on client.