﻿Type.registerNamespace("AjaxControlToolkit");AjaxControlToolkit.DynamicPopulateBehavior=function(a){AjaxControlToolkit.DynamicPopulateBehavior.initializeBase(this,[a]);this._servicePath=null;this._serviceMethod=null;this._contextKey=null;this._cacheDynamicResults=false;this._populateTriggerID=null;this._setUpdatingCssClass=null;this._clearDuringUpdate=true;this._customScript=null;this._clickHandler=null;this._callID=0;this._currentCallID=-1;this._populated=false};AjaxControlToolkit.DynamicPopulateBehavior.prototype={initialize:function(){AjaxControlToolkit.DynamicPopulateBehavior.callBaseMethod(this,"initialize");$common.prepareHiddenElementForATDeviceUpdate();if(this._populateTriggerID){var a=$get(this._populateTriggerID);if(a){this._clickHandler=Function.createDelegate(this,this._onPopulateTriggerClick);$addHandler(a,"click",this._clickHandler)}}},dispose:function(){if(this._populateTriggerID&&this._clickHandler){var a=$get(this._populateTriggerID);a&&$removeHandler(a,"click",this._clickHandler);this._populateTriggerID=null;this._clickHandler=null}AjaxControlToolkit.DynamicPopulateBehavior.callBaseMethod(this,"dispose")},populate:function(contextKey){if(this._populated&&this._cacheDynamicResults)return;if(this._currentCallID==-1){var eventArgs=new Sys.CancelEventArgs;this.raisePopulating(eventArgs);if(eventArgs.get_cancel())return;this._setUpdating(true)}if(this._customScript){var scriptResult=eval(this._customScript);this._setTargetHtml(scriptResult);this._setUpdating(false)}else{this._currentCallID=++this._callID;if(this._servicePath&&this._serviceMethod){Sys.Net.WebServiceProxy.invoke(this._servicePath,this._serviceMethod,false,{contextKey:contextKey?contextKey:this._contextKey},Function.createDelegate(this,this._onMethodComplete),Function.createDelegate(this,this._onMethodError),this._currentCallID);$common.updateFormToRefreshATDeviceBuffer()}}},_onMethodComplete:function(b,a){if(a!=this._currentCallID)return;this._setTargetHtml(b);this._setUpdating(false)},_onMethodError:function(a,b){if(b!=this._currentCallID)return;if(a.get_timedOut())this._setTargetHtml(AjaxControlToolkit.Resources.DynamicPopulate_WebServiceTimeout);else this._setTargetHtml(String.format(AjaxControlToolkit.Resources.DynamicPopulate_WebServiceError,a.get_statusCode()));this._setUpdating(false)},_onPopulateTriggerClick:function(){this.populate(this._contextKey)},_setUpdating:function(a){this.setStyle(a);if(!a){this._currentCallID=-1;this._populated=true;this.raisePopulated(this,Sys.EventArgs.Empty)}},_setTargetHtml:function(b){var a=this.get_element();if(a)if(a.tagName=="INPUT")a.value=b;else a.innerHTML=b},setStyle:function(b){var a=this.get_element();if(this._setUpdatingCssClass)if(!b){a.className=this._oldCss;this._oldCss=null}else{this._oldCss=a.className;a.className=this._setUpdatingCssClass}b&&this._clearDuringUpdate&&this._setTargetHtml("")},get_ClearContentsDuringUpdate:function(){return this._clearDuringUpdate},set_ClearContentsDuringUpdate:function(a){if(this._clearDuringUpdate!=a){this._clearDuringUpdate=a;this.raisePropertyChanged("ClearContentsDuringUpdate")}},get_ContextKey:function(){return this._contextKey},set_ContextKey:function(a){if(this._contextKey!=a){this._contextKey=a;this.raisePropertyChanged("ContextKey")}},get_PopulateTriggerID:function(){return this._populateTriggerID},set_PopulateTriggerID:function(a){if(this._populateTriggerID!=a){this._populateTriggerID=a;this.raisePropertyChanged("PopulateTriggerID")}},get_ServicePath:function(){return this._servicePath},set_ServicePath:function(a){if(this._servicePath!=a){this._servicePath=a;this.raisePropertyChanged("ServicePath")}},get_ServiceMethod:function(){return this._serviceMethod},set_ServiceMethod:function(a){if(this._serviceMethod!=a){this._serviceMethod=a;this.raisePropertyChanged("ServiceMethod")}},get_cacheDynamicResults:function(){return this._cacheDynamicResults},set_cacheDynamicResults:function(a){if(this._cacheDynamicResults!=a){this._cacheDynamicResults=a;this.raisePropertyChanged("cacheDynamicResults")}},get_UpdatingCssClass:function(){return this._setUpdatingCssClass},set_UpdatingCssClass:function(a){if(this._setUpdatingCssClass!=a){this._setUpdatingCssClass=a;this.raisePropertyChanged("UpdatingCssClass")}},get_CustomScript:function(){return this._customScript},set_CustomScript:function(a){if(this._customScript!=a){this._customScript=a;this.raisePropertyChanged("CustomScript")}},add_populating:function(a){this.get_events().addHandler("populating",a)},remove_populating:function(a){this.get_events().removeHandler("populating",a)},raisePopulating:function(b){var a=this.get_events().getHandler("populating");a&&a(this,b)},add_populated:function(a){this.get_events().addHandler("populated",a)},remove_populated:function(a){this.get_events().removeHandler("populated",a)},raisePopulated:function(b){var a=this.get_events().getHandler("populated");a&&a(this,b)}};AjaxControlToolkit.DynamicPopulateBehavior.registerClass("AjaxControlToolkit.DynamicPopulateBehavior",AjaxControlToolkit.BehaviorBase);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();