Turn on thread page Beta
    • Thread Starter
    Offline

    18
    ReputationRep:
    I'm working on a simple login page and have been trying to mask the characters in the textbox. Though it's giving the error mentioned in the title.

    Below is the code:
    Code:
    private void textBox2_TextChanged(object sender, EventArgs e)
    { 
    textBox2.Text = "";
    textBox2.PasswordChar = "*";
    }
    Offline

    19
    ReputationRep:
    In the Page_Load() function can you not just do:

    textBox2.PasswordChar = '*';

    https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    A text box has a property that allows you to set it as a password box and the password character is done for you automatically. You just read the password as .Text() as normal.

    Good luck!
    • Thread Starter
    Offline

    18
    ReputationRep:
    (Original post by ByEeek)
    In the Page_Load() function can you not just do:

    textBox2.PasswordChar = '*';

    https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    A text box has a property that allows you to set it as a password box and the password character is done for you automatically. You just read the password as .Text() as normal.

    Good luck!
    :rofl:

    Just noticed it was single-line quotations!:banghead: :yikes:


    Think a visit to the opticians is needed
    Offline

    19
    ReputationRep:
    (Original post by Binary Freak)
    :rofl:

    Just noticed it was single-line quotations!:banghead: :yikes:


    Think a visit to the opticians is needed
    I can talk. It seems I didn't read your question quite right. But hey ho - got there in the end. Yeah - single quotes for characters. Double quotes for strings.
    • Thread Starter
    Offline

    18
    ReputationRep:
    (Original post by ByEeek)
    I can talk. It seems I didn't read your question quite right. But hey ho - got there in the end. Yeah - single quotes for characters. Double quotes for strings.
    Regardless, thanks!
    Offline

    19
    ReputationRep:
    Alternatively you could set the UseSystemPasswordChar property to true
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: November 7, 2015
Poll
Do you think parents should charge rent?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.