Wednesday, February 19, 2014

Store login details in windows application/WPF

Introduction :

Windows application doesn't maintain any state. To store login details like user id, username, password, name etc, you can use global variable.
Store all information in global static variable which can be declare at once and you can access it any where in the program.

public static class UserDetails
    {
      public static string UserName
      {
          get;
          set;
      }
      public static string Password
      {
          get;
          set;
      }
     public static string Name
{
get;
set;
}
    }

After Login you can store all the information in these variable.
if user is validated then store information in this way which as given below.

Login code:

UserDetails.UserName=txtUserName.Text;
 UserDetails.Password=txtPassword.Text;
 //UserDetails.Name=Fetch Name from database if username and password is valid.

No comments :

Post a Comment