JS技术

javaScript自定义绑定

字号+ 作者: 来源:    2014-11-17 20:00 我要评论( )

javaScript自定义绑定,阅读javaScript自定义绑定,script type =

<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>

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • 学习JavaScript之this,call,apply

    学习JavaScript之this,call,apply

    2016-01-28 20:45

  • 轻松学习JavaScript十五:JavaScript之BOM简介 - 连宏伟 - 博客频道 - CSDN.NET 连宏

    轻松学习JavaScript十五:JavaScript之BOM简介 - 连宏伟 - 博客频道

    2015-12-13 11:34

  • javaScript自定义绑定_javascript教程教程

    javaScript自定义绑定_javascript教程教程

    2015-10-04 08:10

  • 学习Javascript数组_Javascript教程

    学习Javascript数组_Javascript教程

    2015-10-02 09:18

网友点评