如何像文本框一样输入标签文本模式作为密码模式 [英] how to enter label text mode as password mode like a textbox
本文介绍了如何像文本框一样输入标签文本模式作为密码模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
一般情况下我们将文本框Textmode作为密码。
类似我想要的标签Textmode作为密码格式
有什么办法请帮帮我
先谢谢。
解决方案
我不知道你为什么要这个?无论如何,创建新的用户控件并在其上添加标签,然后,在后面的代码中添加一个Text属性:
private string _text = string .empty;
public string 文字
{
get
{
return _text;
}
set
{
_text = value ;
lblMyLabel.Text = ;
foreach ( char c in value )
lblMyLabel.Text + = *跨度>;
}
}
然后你只需将用户控件添加到你的页面我猜!多数民众赞成,如果我理解你的问题。
为什么你想要一个密码格式标签?用户无法输入,他无法阅读,但是由于右键单击并且查看源会将密码显示为任何想要使用它的人的明文,因此将完全不安全。
我注意到你想要它就像一个文本框所以它不是用户输入的 - 你想要实现什么,你认为这会解决你的问题?可能有更好的方法。
如果您打算使用UseSystemPassword = true
显示文本框的密码,然后它就像OrginalGriff上面说的那样很容易被检索。
除非你这样做:虽然我不确定它有多安全
foreach ( char ch textBox1.Text.ToCharArray())
{
label1.Text + = *;
}
< br />
使用VS2005完成
Hi All,
Generally we have textbox Textmode as password.
Similarlly I want label Textmode as password format
Is there any way please help me
Thanks in Advance.
解决方案
I dont know why you would want this?? Anyway, create new User Control and add a label on it, then, in the code behind add a Text property:
private string _text = string.empty; public string Text { get { return _text; } set { _text = value; lblMyLabel.Text = ""; foreach(char c in value) lblMyLabel.Text += "*"; } }
Then you just add that user control to your page I guess! Thats if I am understanding your question.
Why would you want a password format label? The user can't enter it, he can't read it, but is would be completely insecure since a right click and "view source" would show the password as clear text to anyone who wanted to use it.
I noticed you want it "like a textbox" so it isn't for user input - what are you trying to achieve that you think this will solve your problem? There may be a better way to do that.
If you are planning to show password of textbox to label usingUseSystemPassword = true
, then it can be retrieved very easily just as OrginalGriff said above.
unless you do this: though i am not sure how much secure is it
foreach(char ch in textBox1.Text.ToCharArray()) { label1.Text += "*"; }
<br /> Done using VS2005
这篇关于如何像文本框一样输入标签文本模式作为密码模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文