zoukankan      html  css  js  c++  java
  • .NET TextBox设置密码格式,通过按钮切换是否显示密码

    页面展示:

    点击按钮密码展示,图片切换,再点击密码隐藏图片切换

     实现:

    1、页面

        <asp:TextBox MaxLength="24"  ID="tbWebSite_UserPwd1" runat="server" TextMode="Password"></asp:TextBox>
    
        <asp:ImageButton runat="server" ID="btnShowClose" BorderWidth="0" ImageUrl="~/qdAdmin/qdimages/yanjing_xianshi.png" OnClick="btnShowClose_Click"/>

    2、后面方法

      protected void btnShowClose_Click(object sender, EventArgs e)
        {
            //记住密码
            this.tbWebSite_UserPwd1.Attributes.Add("value", this.tbWebSite_UserPwd1.Text);
            this.tbWebSite_UserPwd2.Attributes.Add("value", this.tbWebSite_UserPwd2.Text);
            ImageButton btn = (ImageButton)sender;
            if (btn.ID == "btnShowClose")
            {
     
                if (tbWebSite_UserPwd1.TextMode == TextBoxMode.Password)
                {
                    //密码显示 与切换图片
                    tbWebSite_UserPwd1.TextMode = TextBoxMode.SingleLine;
                    btnShowClose.ImageUrl = "~/qdAdmin/qdimages/yanjing_yincang.png";
                }
                else
                {
                    tbWebSite_UserPwd1.TextMode = TextBoxMode.Password;
                    btnShowClose.ImageUrl = "~/qdAdmin/qdimages/yanjing_xianshi.png";
                }
    
            }else if (btn.ID == "btnShowClose2")
            {
               
                if (tbWebSite_UserPwd2.TextMode == TextBoxMode.Password)
                {
                    tbWebSite_UserPwd2.TextMode = TextBoxMode.SingleLine;
                    btnShowClose2.ImageUrl = "~/qdAdmin/qdimages/yanjing_yincang.png";
                }
                else
                {
                    tbWebSite_UserPwd2.TextMode = TextBoxMode.Password;
                    btnShowClose2.ImageUrl = "~/qdAdmin/qdimages/yanjing_xianshi.png";
                }
            }
        }
  • 相关阅读:
    7.15--7.19学习小结
    关于CStdioFile的使用问题
    【EOJ Monthly 2018.7】【D数蝌蚪】
    【HDOJ1051】【排序+LIS】【贪心】
    【HDOJ1045】【DFS】
    【递推】【HDOJ】
    【带权并查集】【HDOJ】
    【次小生成树】【Kruskal】【prim】【转】
    【HDOJ4857】【反向拓扑排序】
    【HDOJ1069】【动态规划】
  • 原文地址:https://www.cnblogs.com/obge/p/15797084.html
Copyright © 2011-2022 走看看