C# how to get text value from PasswordBox?

假如想象 提交于 2019-11-29 02:47:29

You can get it from the Password property.

Death Zone

You may extract it from Password property:

passwordBox.Password.ToString()

If using a MaskedTextbox you can use the .text property. For example:

private void btnOk_Click(object sender, EventArgs e)
{
    if ( myMaskedTextbox.Text.Equals(PASSWORD) )
    {
        //do something
    }         

}

I use below code to get the length of PasswordBox

PasswordVariableName.Password.Length

It will certainly work on wp8

jiciftw

You may not want to store the password in clear text in memory, from the msdn doc you should use SecurePassword in order to prevent that.

Example: SecureString myPass = passwordBox.SecurePassword

https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.passwordbox.securepassword

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!