C#-> textBox1.PasswordChar

  • Thread starter Thread starter Hareth
  • Start date Start date
H

Hareth

Is there a way to take a text, from a textbox & later passwordChar the text.
I'm not using a masked textbox.

I tried:

textBox1.PasswordChar = '*';

but this didn't change my text. I know how to passwordchar, but I don't know
how to take a text THEN passwordchar it...Any code samples will be great!

please keep it simple b/c im a beginner
 
You need to reset the text in the TextBox after assigning PasswordChar:

textBox1.PasswordChar = '*';
textBox1.Text = textBox1.Text;

HTH,
Robert
 
It did not work


Robert Misiak said:
You need to reset the text in the TextBox after assigning PasswordChar:

textBox1.PasswordChar = '*';
textBox1.Text = textBox1.Text;

HTH,
Robert
 
Hello Hareth,

I don't think the assignment:
textBox1.Text = textBox1.Text;
will work because it detects that it is the same and will not actually reset the text to the same value.

You could possibly try this:

textBox1.PasswordChar = '*'
string tmp = textBox1.Text;
textBox1.Clear();
textBox1.Text = tmp;

This seems like such a hack but I don't know of any other way right now.

HTH
Wes Haggard
http://weblogs.asp.net/whaggard/
 
doesnt work


Robert Misiak said:
You need to reset the text in the TextBox after assigning PasswordChar:

textBox1.PasswordChar = '*';
textBox1.Text = textBox1.Text;

HTH,
Robert
 
Back
Top