Monday, March 26, 2012

My extender control wires its events, then seems to forget what it is!

I've created an extender using the Ajax Extender Control Template. It takes a TextBox as its TargetControl and adds a couple of drop downs to its child controls. Then it responds to the onblur event of the text box. It is supposed to set the values of the drop downs before it posts back. The problem is that when the text box fires its 'blur' event I can't use the 'this' keyword to refer to any of the classes properties or methods. Here is a brief snippett:

Company.Web.MASW.ProductAutoCompleteBehavior.prototype = { initialize : function() { Company.Web.MASW.ProductAutoCompleteBehavior.callBaseMethod(this,'initialize'); $addHandler(this.get_element(),'blur',this._elementChanged ); $addHandler(this._DiameterElement,'click',this._setElementValue ); $addHandler(this._TypeElement,'click',this._setElementValue ); },... _elementChanged : function(e) { alert(this.get_element()); }, _setElementValue : function(e) { alert( this._DiameterElement ); }}
 

The alert commands just verify that I've managed to make the connection to the right input element. It should pop up and say [object] but I get a script error saying object does not support this property or method. I just can't understand how it's calling the right event but can't see it's own properties. Could It be that it's inheriting from the AjaxToolkit.BehaviorBase class?

It seems as though I have a lot to learn about how to connect everything in Ajax. I've done a fair amout of JavaScript and I've done a fair amount of JScript in ASP. I have got a lot to learn about how Ajax connects ECMA, EMCA, E=MC2, or what ever it's called. I just can't fool with it much more for now so consider this 'resolved'. Thanks to all those who read this and said "what in the world is he up to?"

No comments:

Post a Comment