当前位置:首页 > 网络编程 > WEB编程 > ASP.net >  ECMAScript基础类以及Asp.net Ajax对类Object的扩展2

 ECMAScript基础类以及Asp.net Ajax对类Object的扩展2

点击次数:32 次 发布日期:2008-11-26 11:03:06 作者:源代码网
源代码网推荐      从上面我们可以看到,Object.getType(type)这个静态方法可以获取一个类的对象,而Object.getTypeName(type)通过调用[prototype]Type.getName()而获取类的名(包括命名空间)。这没有什么好说的,下面来看一下测试:
源代码网推荐  
源代码网推荐   <asp:ScriptManager ID="ScriptManager1" runat="server" />
源代码网推荐  
源代码网推荐   <div>
源代码网推荐  
源代码网推荐   <script language="javascript">
源代码网推荐  
源代码网推荐   Type.registerNamespace("NExplus");
源代码网推荐  
源代码网推荐   //define a class;
源代码网推荐  
源代码网推荐   NExplus.ObjectTest=function(name){
源代码网推荐  
源代码网推荐   this._name=name;
源代码网推荐  
源代码网推荐   }
源代码网推荐  
源代码网推荐   NExplus.ObjectTest.prototype.getName=function(){
源代码网推荐  
源代码网推荐   return (this._name === undefined) ? null : this._name;
源代码网推荐  
源代码网推荐   }
源代码网推荐  
源代码网推荐   NExplus.ObjectTest.prototype.setName=function(name){
源代码网推荐  
源代码网推荐   this._name=name;
源代码网推荐  
源代码网推荐   }
源代码网推荐  
源代码网推荐   //register class;
源代码网推荐  
源代码网推荐   NExplus.ObjectTest.registerClass("NExplus.ObjectTest");
源代码网推荐  
源代码网推荐  
源代码网推荐  
源代码网推荐   NExplus.TestObject=function(){
源代码网推荐  
源代码网推荐   var a=new NExplus.ObjectTest("Test is success?");
源代码网推荐  
源代码网推荐   document.write(a.getName());
源代码网推荐  
源代码网推荐   document.write("<br/>");
源代码网推荐  
源代码网推荐   a.setName("Success!");
源代码网推荐  
源代码网推荐   document.write(a.getName());
源代码网推荐  
源代码网推荐   document.write("<br/>");
源代码网推荐  
源代码网推荐   document.write(Object.getTypeName(a)+"<br/>")
源代码网推荐  
源代码网推荐   }
源代码网推荐  
源代码网推荐   //run;
源代码网推荐  
源代码网推荐   NExplus.TestObject();
源代码网推荐  
源代码网推荐   </script>
源代码网推荐  
源代码网推荐   </div>
源代码网推荐  
源代码网推荐  运行结果:
源代码网推荐  
源代码网推荐  Test is success?
源代码网推荐  Success!
源代码网推荐  NExplus.ObjectTest
源代码网推荐  
源代码网推荐   这个比较简单,微软只是为了和.NET框架更接近而扩展的Object类,我觉得这两个在开发过程中应该很少用到吧,上面的测试顺便测试一下属性J。我很想知道有没有那个好心人翻译了ECMAScript的规范文档,看英文真的好类;<.顺便附上一只捆牢我的两个操作符: ||:从第一个开始,遇到有意义的返回,否则返回最后一个表达式(不一定是Boolean值); &&:从第一个开始,遇到无意义(0,null,undefined,"",false,NaN)的返回,否则返回最后一个表达式(不一定是Boolean值)。
源代码网推荐  
源代码网推荐  http://www.cnblogs.com/xdotnet/archive/2006/12/25/nexplus_aspnet_ajax_object_extend.html
源代码网推荐  
源代码网推荐  
源代码网推荐    做人要厚道,请注明转自酷网动力(www.ASPCOOL.COM)。
源代码网推荐


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华