【IT168技术文档】
我们一步一步地来实现这个控件:
1、编写一个类,并继承于Sys.UI.Control或其子类。
Jeffz.UI.CultureSelector类的代码框架如下
1Type.registerNamespace("Jeffz.UI"); 2 3Jeffz.UI.CultureSelector = function(associatedElement) 4{ 5 Jeffz.UI.CultureSelector.initializeBase(this, [associatedElement]); 6 7 ... 8 9 this.get_culture = function() 10 { 11 return _culture; 12 } 13 14 this.set_culture = function(value) 15 { 16 if (!this.get_isInitialized()) 17 { 18 _culture = value; 19 return; 20 } 21 22 if (_culture == value) 23 { 24 return; 25 } 26 27 var cancelArgs = new Sys.CultureCancelEventArgs(value); 28 this.cultureChanging.invoke(this, cancelArgs); 29 canceled = cancelArgs.get_canceled(); 30 31 if (!canceled) 32 { 33 _culture = value; 34 this.__updateCulture(); 35 this.raisePropertyChanged('culture'); 36 } 37 38 this.__changeSelectedOption(_culture); 39 } 40 41 this.get_isLoading = function() 42 { 43 return _isLoading 44 } 45 46 this.cultureChanging = new Type.Event(this); 47 48 ... 49} 50Jeffz.UI.CultureSelector.registerClass('Jeffz.UI.CultureSelector', Sys.UI.Control);