C#-> textBox1.PasswordChar

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
 
R

Robert Misiak

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

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

HTH,
Robert
 
H

Hareth

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
 
W

Wes

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/
 
H

Hareth

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top