locked
Reset Textbox.PasswordChar C# RRS feed

  • Debate general

  • 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!

    domingo, 16 de marzo de 2008 12:51

Todas las respuestas

  • Try setting it to null
    domingo, 16 de marzo de 2008 13:24
  • Set null doesn't work: "Cannot convert null to 'char' because it is a value type"

    domingo, 16 de marzo de 2008 14:04
  •  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;

    domingo, 16 de marzo de 2008 14:06
  • or this.myTextBox.PasswordChar = "";
    domingo, 16 de marzo de 2008 14:09
  • Nothing works... Both methods give this error: "Cannot implicitly convert type 'string' to 'char'"

    domingo, 16 de marzo de 2008 14:20
  • try '' instead of ""
    domingo, 16 de marzo de 2008 14:25
  •  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.

    domingo, 16 de marzo de 2008 14:34
  • myTextBox.PasswordChar = '' gives the error "Empty character literal"

    domingo, 16 de marzo de 2008 14:35
  •  Jokkiw007 wrote:

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

     

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

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

    domingo, 16 de marzo de 2008 14:40
  • try this '\0'

     textBox1.PasswordChar = '\0';
    domingo, 16 de marzo de 2008 14:45
  • 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'

     

    domingo, 16 de marzo de 2008 14:49
  •  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.

    domingo, 16 de marzo de 2008 16:27
  • jueves, 10 de julio de 2008 6:52
  • thanks guys.

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

                       if (Common.IsSuperAdmin)
                            txtPassword.PasswordChar = new char();
                        else
                            txtPassword.PasswordChar = '*';
    sábado, 14 de noviembre de 2009 11:39
  • Since we are all giving options on how to write it ;-)

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

    jueves, 1 de abril de 2010 13:07
  • oK, workit tanks a lot

    smuel
    jueves, 24 de marzo de 2011 14:14
  • 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;
    sábado, 26 de marzo de 2011 17:35
  • Thanks its really nice of you.

     

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

    viernes, 25 de noviembre de 2011 7:00
  • try this '\0'

     textBox1.PasswordChar = '\0';
    thank you very much MEYWD
    jueves, 26 de enero de 2012 16:51
  • Thanks, that was what I needed!
    miércoles, 30 de mayo de 2012 20:23
  • Nice code, man. =) I did this too.
    viernes, 20 de julio de 2012 11:36
  • though one and the same thing but this is another way out:

     textBox1.PasswordChar = (char)0;

    miércoles, 20 de noviembre de 2013 21:12
  • 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

    miércoles, 29 de enero de 2014 8:46
  • using this code to set null Password character

    textBox1.PasswordChar = (char)0;

    or this

    textBox1.PasswordChar = '\0';
    domingo, 16 de febrero de 2014 15:58
  • Gracias me funciono excelente ....!!!!
    sábado, 5 de diciembre de 2015 16:49
  • Thank you ! this is worked  !

    viernes, 5 de febrero de 2016 9:12
  • try this '\0'

     textBox1.PasswordChar = '\0';

    katangahan to wag nyo sundin

    jueves, 4 de enero de 2018 1:35
  • Dude! It worked but what this character '/0' means???
    jueves, 5 de abril de 2018 11:42
  • The only one that really work for  VB.net is:

    txtTextBox1.PasswordChar = Nothing


    • Editado Nandostyle miércoles, 27 de junio de 2018 22:07
    miércoles, 27 de junio de 2018 22:04
  • try this '\0'

     textBox1.PasswordChar = '\0';

    The text is totally back again.

    Thanks a lot !

    miércoles, 10 de abril de 2019 17:43
  • this is the correct answer.

    whenever you cannot find what you need, try print the default value in some place like console (it will be printed in output view).

    for example i wrote this code when my text box PasswordChar was empty:

    Console.WriteLine((int)txtPassword.PasswordChar);

    and then in output view 0 was displayed for me. therefore i used this code and it worked:

    txtPassword.PasswordChar = (char)0;

    miércoles, 28 de agosto de 2019 7:31
  • Cool, it works. Thx. 
    domingo, 30 de agosto de 2020 20:01