I have a Login page that captures User input like this.
MD5calc ss = new DBCon.MD5calc();
string gs = ss.CalculateMD5Hash(password.Password);
int unitID = Convert.ToInt32(Unit_ID.Text);
logBO.UnitID = unitID;
logBO.UserID = User_name.Text;
logBO.UserPass = gs;
How would i make them assignable to any other page i created.My Common sense says that creating a static class would be enough,but will it?If i do create a static class where would i put it and how would i call it?I actually need those variable to use in my Sql Stored procedures.
If Web-based:
I don’t think a static class’ll work as the values will be application-wide in scope and thus not attached to a specific user but the last user that logged in
Sinple solution would be to put them in some sort of session variable
Possibly better method would be to create an Authentication Cookie and attach the necessary values to that – and I’m in the wrong place for fishing out a quick example (sorry)
If WinApp based:
Yes – just create a public static class with static properties – the static constructor will run the first time you attempt to use the class …
Quick example:
// Syntax may be a bit ropeypublic static class LoginDetails {
public static string Username { get; set; }
public static int UnitID { get; set; } public static string Password { get; set; } }
This can be used just as:
// Assign the value LoginDetails.Password = password; // Get the value string password = LoginDetails.PasswordCos it’s a static, you never need to initialise it with “new”