WEB开发网
开发学院网页设计JavaScript javaScript自定义绑定 阅读

javaScript自定义绑定

 2008-08-25 19:59:32 来源:WEB开发网   
核心提示:<script type = "text/javascript"> function pageLoad() { var text = new Sys.UI.TextBox($('text')); var label = new Sys.UI.Label($(
<script type = "text/javascript">
     function pageLoad()
     {
       var text = new Sys.UI.TextBox($('text'));
       var label = new Sys.UI.Label($('label'));
       text.set_text("Hello,world!");
      
      
       var binding_1 = new Sys.Binding();
       binding_1.set_dataContext(text);
       binding_1.set_dataPath('text');
       binding_1.set_PRoperty('text');
       binding_1.transform.add(customTransform);
      
      
       label.get_bindings().add(binding_1);
       text.initialize();
       label.initialize();
     }
     function customTransform(sender,eventArgs)
     {
       var value = eventArgs.get_value();
       var reverseStr = new Sys.StringBuilder();
       for(var i = value.length - 1;i >= 0;i--)
       {
        
         reverseStr.append(value.charAt(i));
         eventArgs.set_value(reverseStr.toString());
       }
     }
   </script>
</head>
<body onload = "pageLoad();">
   <form id="form1" runat="server">
     <atlas:scriptmanager ID = "scriptmanager" runat="server"></atlas:scriptmanager>
     <div>
       <h3><u>Example 3:</u></h3>
       <div id = "font">
         This example binds the label(a span element) to the text box and <br />
         demonstrates a custom transform to reverse the text from th entered<br />
         value.<br />
         Enter a string:<input type = "text" id = "text" runat = "server" /><br />
         Reversed Text:<label id = "label" runat = "server"></label>
       </div>
     
     </div>
      
   </form>

Tags:javaScript 定义 绑定

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接