in asp.net we maintain the value through session but we use window form then how to maintain value of one window form to another form (like session)
in c#.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ankur JainPosted Jul 1, 2015, 2:28 PM
For e.g.
Create a Static class that holds the User name and password and any other variables needed across the application .
In your case it would be something like:
public static class LoginInfo
{
public static string UserID;
}
Now you can access the UserID simply from anywhere in your code:
MessageBox.Show(LogInfo.UserID);
Or set the values after login like
LogInfo.UserID=TextBox1.Text;