J Jason Oct 20, 2003 #2 just that case is after login, i will have an ID from that user I want to keep track that userID within all the form how can i do??
just that case is after login, i will have an ID from that user I want to keep track that userID within all the form how can i do??
E Eric Cadwell Oct 20, 2003 #3 Create a class with a public static property. Then all classes can set and get the value using the syntax className.propertyName. Here's an example: public class SessionData { private static string userID = ""; public static string UserID { get { return userID; } set {userID = value; } } } Now you can get the value by calling: SessionData.UserID = userID; And read the value via: userID = SessionData.UserID; Alternatively, you could build this into the form's definition by creating a stateful base class form that encapsulates the state information: public class StateForm : System.Windows.Forms.Form { private static string userID = ""; public static string UserID { get { return userID; } set {userID = value; } } } HTH; Eric Cadwell http://www.origincontrols.com
Create a class with a public static property. Then all classes can set and get the value using the syntax className.propertyName. Here's an example: public class SessionData { private static string userID = ""; public static string UserID { get { return userID; } set {userID = value; } } } Now you can get the value by calling: SessionData.UserID = userID; And read the value via: userID = SessionData.UserID; Alternatively, you could build this into the form's definition by creating a stateful base class form that encapsulates the state information: public class StateForm : System.Windows.Forms.Form { private static string userID = ""; public static string UserID { get { return userID; } set {userID = value; } } } HTH; Eric Cadwell http://www.origincontrols.com