【问题标题】:C# password TextBox in a ASP.net websiteASP.net 网站中的 C# 密码文本框
【发布时间】:2012-01-01 18:21:28
【问题描述】:

我正在尝试创建一个 ASP .NET 网站,该网站在用户键入时在注册页面中屏蔽密码。我找到了使用 Windows 窗体的网站,但它不适用于 ASP .NET 网站。

所以如果用户输入密码,它会像这样被屏蔽

 *******

任何关于我如何让它工作的网站或建议都会很棒。

【问题讨论】:

    标签: c# asp.net html passwords


    【解决方案1】:

    使用 ASP.NET 方式:

    <asp:TextBox ID="txtBox1" TextMode="Password" runat="server" />
    

    【讨论】:

      【解决方案2】:

      //在aspx页面中

      <asp:TextBox ID="password" runat="server" TextMode="Password" />
      

      //在MVC cshtml中

      @Html.Password("password", "", new { id = "password", Textmode = "Password" })
      

      【讨论】:

      • 很高兴您也介绍了 ASP .NET MVC。 +1。
      【解决方案3】:

      使用密码输入类型。

      <input type="password" name="password" />
      

      这是一个简单的演示http://jsfiddle.net/cPaEN/

      【讨论】:

        【解决方案4】:

        @JohnHartsock:你也可以写 type="password"。在 aspx 中是可以接受的。

        <asp:TextBox ID="txtBox" type="password" runat="server"/>
        

        【讨论】:

        • 这很好,但我总是有这种强迫症......其中属性 casename 必须是 ASP.NET 格式的......:P +1 顺便说一句!
        【解决方案5】:

        我想这就是你要找的东西

         <asp:TextBox ID="txbPass" runat="server" TextMode="Password"></asp:TextBox>
        

        【讨论】:

          【解决方案6】:

          只需选择 texbox 属性 'TextMode' 并选择密码...

          <asp:TextBox ID="TextBox1" TextMode="Password" runat="server" />
          

          【讨论】:

            猜你喜欢
            • 2013-05-20
            • 2015-01-20
            • 2014-05-22
            • 2011-12-20
            • 2010-12-14
            • 1970-01-01
            • 2011-10-21
            • 2011-10-11
            • 2014-05-31
            相关资源
            最近更新 更多