none
Reset Textbox.PasswordChar C#

    Question

  • Hello!

    I know how to set the password char of a textbox (this.myTextBox.PasswordChar = '*'). But how can I reset the password char so the text in the textbox is shown as normal text again?

    Thanks in advance!

    Sunday, March 16, 2008 12:51 PM

Answers

All replies

  • Try setting it to null
    • Proposed as answer by moorypc Sunday, February 16, 2014 4:01 PM
    • Unproposed as answer by moorypc Sunday, February 16, 2014 4:01 PM
    Sunday, March 16, 2008 1:24 PM
  • Set null doesn't work: "Cannot convert null to 'char' because it is a value type"

    Sunday, March 16, 2008 2:04 PM
  •  Jokkiw007 wrote:

    Hello!

    I know how to set the password char of a textbox (this.myTextBox.PasswordChar = '*'). But how can I reset the password char so the text in the textbox is shown as normal text again?

    Thanks in advance!

     

    this.myTextBox.PasswordChar = String.Empty;

    Sunday, March 16, 2008 2:06 PM
  • or this.myTextBox.PasswordChar = "";
    Sunday, March 16, 2008 2:09 PM
  • Nothing works... Both methods give this error: "Cannot implicitly convert type 'string' to 'char'"

    Sunday, March 16, 2008 2:20 PM
  • try '' instead of ""
    Sunday, March 16, 2008 2:25 PM
  •  MEYWD wrote:
    try '' instead of ""

     

    I am sorry,

     

    You should use:

     

    PasswordChar = Convert.ToChar (" ");

     

    or:

    PasswordChar = (char)(byte)32;

     

    or:

    PasswordChar = ' ';  // note: a pair of SINGLE quotes not one double quote.

    Sunday, March 16, 2008 2:34 PM
  • myTextBox.PasswordChar = '' gives the error "Empty character literal"

    Sunday, March 16, 2008 2:35 PM
  •  Jokkiw007 wrote:

    myTextBox.PasswordChar = '' gives the error "Empty character literal"

     

    Yep, just put an empty space (blank) in between them.

    Sunday, March 16, 2008 2:37 PM
  • PasswordChar = Convert.ToChar (" "); does not solve my problem. The text is now masked with spaces! The same with PasswordChar = (char)(byte)32; and PasswordChar = ' ';

    Sunday, March 16, 2008 2:40 PM
  • try this '\0'

     textBox1.PasswordChar = '\0';
    Sunday, March 16, 2008 2:45 PM
  • Thanks for all the help from all of you. But the answer to clear the PasswordChar property is to set the value equal to '\0'

     

    Sunday, March 16, 2008 2:49 PM
  •  Jokkiw007 wrote:
    Thanks for all the help from all of you. But the answer to clear the PasswordChar property is to set the value equal to '\0'

     

    It's very good to know.

    Sunday, March 16, 2008 4:27 PM
  • Thursday, July 10, 2008 6:52 AM
  • thanks guys.

    Here is c# :P
                if (cbShowPassword.Checked)
                    tbPassword.PasswordChar = char.Parse("\0");
                else
                    tbPassword.PasswordChar = char.Parse("*");
    Sunday, July 12, 2009 2:58 AM
  • Hi
    try

                       if (Common.IsSuperAdmin)
                            txtPassword.PasswordChar = new char();
                        else
                            txtPassword.PasswordChar = '*';
    • Proposed as answer by Dhori Alpesh Saturday, November 14, 2009 11:39 AM
    Saturday, November 14, 2009 11:39 AM
  • Since we are all giving options on how to write it ;-)

    textBoxPassword.PasswordChar = (checkBoxShowPW.Checked) ? '*' : '\0';

    Thursday, April 01, 2010 1:07 PM
  • oK, workit tanks a lot

    smuel
    Thursday, March 24, 2011 2:14 PM
  • Hello!

    I know how to set the password char of a textbox (this. myTextBox.PasswordChar = '*'). But how can I reset the password char so the text in the textbox is shown as normal text again?

     

    Thanks in advance!

    this.myTextBox.PasswordChar = char.MinValue;
    Saturday, March 26, 2011 5:35 PM
  • Thanks its really nice of you.

     

    Helped me a lot!!!!!!!!!!111

    Friday, November 25, 2011 7:00 AM
  • try this '\0'

     textBox1.PasswordChar = '\0';
    thank you very much MEYWD
    • Proposed as answer by Kennedy Alvino Thursday, May 31, 2012 11:35 AM
    • Unproposed as answer by Kennedy Alvino Thursday, May 31, 2012 11:35 AM
    Thursday, January 26, 2012 4:51 PM
  • Thanks, that was what I needed!
    Wednesday, May 30, 2012 8:23 PM
  • Nice code, man. =) I did this too.
    Friday, July 20, 2012 11:36 AM
  • though one and the same thing but this is another way out:

     textBox1.PasswordChar = (char)0;

    Wednesday, November 20, 2013 9:12 PM
  • For VB.NET

    txtAuthCode.PasswordChar = Char.MinValue


    Theo Jacobs | DTTC Data Developer (MCT, MCP, MCPD, MCTS, MCAS) Desmond Tutu TB Centre | Department of Pediatrics and Child Health Faculty of Health Sciences | Stellenbosch University | South Africa Phone (27) 21 938 9655 | Fax (27) 21 938 9719 jacobst@sun.ac.za | http://www.sun.ac.za/tb

    Wednesday, January 29, 2014 8:46 AM
  • using this code to set null Password character

    textBox1.PasswordChar = (char)0;

    or this

    textBox1.PasswordChar = '\0';
    Sunday, February 16, 2014 3:58 PM