1: /// <reference name="AjaxControlToolkit.ExtenderBase.BaseScripts.js" assembly="AjaxControlToolkit" />
2:
3: Type.registerNamespace('AJAXControls.KeyUpTextBox');
4:
5: AJAXControls.KeyUpTextBox.KeyUpTextBoxBehavior = function(element) {
6:
7: AJAXControls.KeyUpTextBox.KeyUpTextBoxBehavior.initializeBase(this, [element]);
8: this._UpdateControlIDValue = null;
9: this._ContainerControlIDValue = null;
10: this._Counter = 0;
11: this._MinLengthValue = 3;
12: this._ScriptLocationValue = null;
13: this._ScriptNameValue = null;
14: this._TimeOutValue = 1000;
15: }
16:
17: AJAXControls.KeyUpTextBox.KeyUpTextBoxBehavior.prototype = {
18:
19: initialize: function() {
20: AJAXControls.KeyUpTextBox.KeyUpTextBoxBehavior.callBaseMethod(this, 'initialize');
21: Sys.UI.DomEvent.addHandler(this.get_element(), 'keyup',
22: Function.createDelegate(this, this._onkeyup));
23: this._onkeyup();
24: },
25:
26: dispose: function() {
27: AJAXControls.KeyUpTextBox.KeyUpTextBoxBehavior.callBaseMethod(this, 'dispose');
28: },
29:
30: _onkeyup: function() {
31: var NumKeys = this.get_element().value.length;
32: if (NumKeys >= this._MinLengthValue) {
33: var e = this.get_element().value;
34: ++this._Counter;
35:
36: Sys.Net.WebServiceProxy.invoke(this._ScriptLocationValue, this._ScriptNameValue, false, { "contextKey": e }, Function.createDelegate(this, this._onMethodComplete), Function.createDelegate(this, this._onMethodError), this._Counter, this._TimeOutValue);
37: }
38: else {
39: if (this._ContainerControlIDValue != null) {
40: $get(this._ContainerControlIDValue).style.display = "none";
41: }
42: else {
43: $get(this._UpdateControlIDValue).style.display = "none";
44: }
45: }
46: },
47:
48: _onMethodComplete: function(result, userContext, methodName) {
49: if (this._Counter == userContext) {
50: if (this._ContainerControlIDValue != null) {
51: $get(this._ContainerControlIDValue).style.display = "block";
52: }
53: else {
54: $get(this._UpdateControlIDValue).style.display = "block";
55: }
56: $get(this._UpdateControlIDValue).innerHTML = result;
57: }
58: },
59:
60: _onMethodError: function(webServiceError, userContext, methodName) {
61: if (this._ContainerControlIDValue != null) {
62: $get(this._ContainerControlIDValue).style.display = "block";
63: }
64: else {
65: $get(this._UpdateControlIDValue).style.display = "block";
66: }
67: if (webServiceError.get_timedOut()) {
68: $get(this._UpdateControlIDValue).innerHTML = AjaxControlToolkit.Resources.DynamicPopulate_WebServiceTimeout;
69: } else {
70: $get(this._UpdateControlIDValue).innerHTML = String.format(AjaxControlToolkit.Resources.DynamicPopulate_WebServiceError, webServiceError.get_statusCode());
71: $get(this._UpdateControlIDValue).innerHTML += this._ScriptLocationValue;
72: $get(this._UpdateControlIDValue).innerHTML += this._ScriptNameValue;
73: }
74: },
75:
76: get_UpdateControlID: function() {
77: return this._UpdateControlIDValue;
78: },
79:
80: set_UpdateControlID: function(value) {
81: this._UpdateControlIDValue = value;
82: },
83:
84: get_TimeOut: function() {
85: return this._TimeOutValue;
86: },
87:
88: set_TimeOut: function(value) {
89: this._TimeOutValue = value;
90: },
91:
92: get_ContainerControlID: function() {
93: return this._ContainerControlIDValue;
94: },
95:
96: set_ContainerControlID: function(value) {
97: this._ContainerControlIDValue = value;
98: },
99:
100: get_MinLength: function() {
101: return this._MinLengthValue;
102: },
103:
104: set_MinLength: function(value) {
105: this._MinLengthValue = value;
106: },
107:
108: get_ScriptLocation: function() {
109: return this._ScriptLocationValue;
110: },
111:
112: set_ScriptLocation: function(value) {
113: this._ScriptLocationValue = value;
114: },
115:
116: get_ScriptName: function() {
117: return this._ScriptNameValue;
118: },
119:
120: set_ScriptName: function(value) {
121: this._ScriptNameValue = value;
122: }
123: }
124:
125: AJAXControls.KeyUpTextBox.KeyUpTextBoxBehavior.registerClass('AJAXControls.KeyUpTextBox.KeyUpTextBoxBehavior', AjaxControlToolkit.BehaviorBase);