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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ankur JainRank #2,475 · 567 reputationPosted Jul 1, 2015, 10:28 AM EDT
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;