If you're using Forms Authentication - and it sounds as though you should
be - then you can get the user's credentials from the Identity propery of
the GenericPrincipa l object. Look up GenericPrincipa l in MSDN and follow
the trail to GenericIdentity for examples of how this works. Basically, the
Name property of the GenericPrincipa l's Identity property gives you what you
want.
If you need to roll your own you have several options. The easiest is just
to store the string in the Session:
Session["uid"] = strUserName;
You would do this in some convenient event handler in your Login.aspx page
codebehind - usually in the handler for the submit button, I guess, when
someone logs in.
If you're storing more information about your user than just the user name,
you'll probably want to create an object from a class you define, store the
username in that object (along with whatever else you want to put in there),
and store a reference to that object in the Session.
MyUserObj myuserobj = new MyUserObj();
myuserobj.usern ame = strUserName; // assuming username is a property
Session["MyUserObj"] = myuserobj;
Your object is now globally accessible.
Only your own application model (UML or whatever) will tell you which
strategy is best for your application.
HTH
Peter
"Monica" <Mo****@discuss ions.microsoft. comwrote in message
news:DC******** *************** ***********@mic rosoft.com...
Hi,
Sorry, maybe it's so simple. but please let me know.
I have Login.aspx.cs taht has a string variable like strUserName.
I have manage.aspx.cs that I want to get strUserName.
How can I do this?
Thank you.
Monica