刚看到有张帖里有位朋友问怎么用其它符号替换掉密码输入框里的*符号。刚好,我也有个类似于这样的长久的困惑,我的困惑不是实现的技术细节,而是想知道.net framework 是不是开放源代码的?(汗!微软的东西什么时候开放过源代码,不过还是问问。)也就是说我能不能在.net framework的类中找到微软写的用*符号替换输入字符的代码细节?假如如上问题不成立,那经常看见有些朋友说“重写个xxx方法,让它按自己的格示显示...重写DataGrid的xxx,让它实现xxx功能...等等”,我实在不解,如果类中的代码看都看不见,怎么怎么重写它呢?所谓的重写是不是先继承该类,然后只是在原有类中添加一些新的方法?假如我的如上猜测都成立,那么我们现在使用的庞大的.net framework类只不过在使用它的“接口”:一些属性名、字段名、方法名......我们只知道这些名称能完成什么样的功能,而不知道它具体是怎样完成这些功能的,比如密码输入时用*替换输入字符......?盼给予指点,不甚感激!

解决方案 »

  1.   

    这个问题我也不清楚.有些代码好象可以在网上可以找到,看到啊.不过那些是ms提供的么?为什么不象delphi一样直接能看到呢.呵呵.
      

  2.   

    it is not up to you, if you want to use <input type=password>, then you have to take whatever the OS gives you, but I would think you could use <input type=text> to simulate it, for example, something like<input type="text" onkeypress="replaceChar(this)" id="txt1">
    <input type="button" value="click me" onclick="alert(p.join(''))">
    <script language="javascript">
    var p = new Array();
    function replaceChar(txt)
    {
      var k = event.keyCode;
      p.push(String.fromCharCode(k));
      event.keyCode = '$'.charCodeAt(0);
    }
    </script>but you have to take care of backspace, copy/paste,delete.....and put the value back when submitting the form, probably a little more complicated than you thought