wpf - How to use passchar conditionally in c# login form -


i have created login form default shows text 'enter username' in user name text field when 1 clicks on password text field , vice versa shows 'enter password' when clicked on username text field

now want use pwd.passchar = "*" here. password field doesn't shows 'enter password' text *****. should display text unless user starts typing actual password

here code -

public login()     {         initializecomponent();          if (pwd.text == "enter password")         {                          // don't show $$ in password text field         }         else         {             pwd.passwordchar = '*';         }     }    private void textbox1_click(object sender, eventargs e)     {         uname.text = string.empty;          if (string.isnullorwhitespace(pwd.text))         {             pwd.text = "enter password";         }      }  private void textbox2_click(object sender, eventargs e)     {         pwd.text = string.empty;          if (string.isnullorwhitespace(uname.text))         {             uname.text = "enter username"; 

please suggest changes...

play empty string passwordchar , textchanged event

in vb.net

private sub pwd_textchanged(byval sender system.object, byval e system.eventargs) handles pwd.textchanged     if pwd.text = "enter password"         pwd.passwordchar = ""     else         pwd.passwordchar = "*"     end if end sub 

in c#, probe this

    private void pwd_textchanged(object sender, eventargs e)     {         if (pwd.text == "enter password")             pwd.passwordchar = convert.tochar(0);         else if (pwd.text == "")             pwd.text = "enter password";         else            pwd.passwordchar = '*';      } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -