Click here to Skip to main content
15,904,817 members
Please Sign up or sign in to vote.
4.17/5 (3 votes)
See more:
Can I use LoginView Control without Login Control?
I want to display login username on page upto logout. Is it possible without Login Control?
Pls give me some idea.
Posted
Updated 26-Sep-11 0:05am
v2

This would be easier if you use master page in your project , and a dedicated label to display the username in the same master page.

After successful login you can pass the username to a session and pass this session value to the label text.Refer the below code;


if login is successful add the following codein your logic

C#
Session["username"]= txtusername.Text;



And in the master page page load event.


C#
lbl_user_name.Text = Session["username"].ToString();



In this way you can see the username in all the pages in which you are applying the above used masterpage.
 
Share this answer
 
v2
Comments
sravani.v 26-Sep-11 5:05am    
This is good solution
Get the name of the User in Session or from
HttpContext.Current.User.Identity.Name
and show through out the Session.
 
Share this answer
 
Store the user name in Session["userName"] or
HttpContext.Current.User.Identity.Name
and display in all the pages of website
 
Share this answer
 
v3
for this you have to maintain a session object

Syntax Session["object_name","object_value"]
Session.Add("uid",txt_username);

now you can set label on every page using this code

label1.text=Session["uid"].tostring();
 
Share this answer
 
Use session store user name in session and get that user name on master page
then you can see user name or any other information which you store in session on every page.
 
Share this answer
 
v2
You can use session & querying string.


**session**

Session["username"]= txtusername.Text;

**querying string**

Passing variables between pages using QueryString[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900