如何显示passwordchar隐藏的密码 [英] how to show password hidden by passwordchar

查看:369
本文介绍了如何显示passwordchar隐藏的密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为passwordtextbox的文本框,其passwordchar属性为*以隐藏密码。我还有一个名为show的按钮来显示passwordchar隐藏的密码。请在c#中如何进行操作我需要帮助?

i have a textbox named passwordtextbox which has the passwordchar property of * to hide passwords. I also have a button named show to show passwords hidden by the passwordchar.Please i need help on how to go about it in c#?

推荐答案

将PasswordChar设置为\ 0 ...

Set PasswordChar to \0...
this.password.passwordchar='\0';


试试这个显示密码:

Try this to show password:
passwordtextbox.PasswordChar = char.MinValue;





我建议用checkBox替换show按钮,并且:



I suggest to replace the show button with checkBox and:

private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
   this.passwordtextbox.PasswordChar = this.checkBox1.Checked ? char.MinValue : '*';
}


对于Web应用程序,请使用下面给出的代码



For web application use code given below

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
TextBox1.TextMode = (CheckBox1.Checked ? TextBoxMode.SingleLine : TextBoxMode.Password);
}







对于Windows应用程序,请使用下面给出的代码






For windows application use code given below

 private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
textBox1.PasswordChar = (checkBox1.Checked ? char.MinValue : '*');
}


这篇关于如何显示passwordchar隐藏的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆