简体   繁体   中英

C# How can I get masked password from textbox?

I've set property of my textbox1 with PasswordChar = '*' and textbox display correct text that is ****.

But when I want to use that masked text (****) by set label1.text = textbox1.text, why label1.text show plain password text which not masked and how can I get masked text from my textbox1?

To use a TextBox for passwords, just set the PasswordChar value to anything other than NULL and it will automatically hide the characters typed.

This is purely for display purposes and so if you copy the text elsewhere it won't be hidden.

Then you should customize the label to display text as masked and you should extended PasswordChar property to label.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM