move text box to other part of application

  • Thread starter Thread starter ronenk
  • Start date Start date
R

ronenk

I have a good authentication form, which I use to login to my app. Now
I want to be able to know which user is logged in now, in order to fill
his answers in DB. In other words: I need to save & move username
(stored in text box of the authentication form) to other parts of
application. How would I do that?

TIA,
Ronen
 
keep it in the session.

if this is a win app keep it in a static variable in an Auth class or
something like that.


cheers,
 
This is not such agood idea, as the veriable will not keep the name
after function is through.
note: I call USR from a different form
this is the function:
private void btnOK_Click(object sender, EventArgs e)
{
DAL dal= new DAL();
if (dal.userExists(boxUserName.Text,
Int32.Parse(boxPassword.Text))==true)
{
this.DialogResult = DialogResult.OK;
}
else
MessageBox.Show("Wrong username or password. Please try again or open
new user");
USR=boxPassword.Text.ToString();.Text.ToString();
}

tried it and it wasn't useful.

P.S: USR is global variable.
 
hi

you do not keep the textbox, you keep the loginname.

and USR CANNOT be a global variables as there is not such a thing in C# :)

use somethign like this:

class CurrentUser
{
static string loginname="";
static public string Login{ get{ return loginname;} set { loginname=value;}}
}

then in your auth dialog, after you check that the login/password is correct
you do:

CurrentUser.Login = boxUserName.Text;

after that the login is accesible globally as CurrentUser.Login


cheers,
 
Back
Top