Click here to Skip to main content
15,904,348 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
Dear Friends,

I want to display Users Full name in label after user log in.
==================================================================

I have Two Pages
1) Login Page
2) Welcome Page

and a Registration page...In this Registration page Administrator will create users.. so that users can log in to this application.

In Registration page I have fields as
UserName, FirstName, LastName, Department, MobileNo


In Welcome page it must show Users Full Name.

I want to Display the full name with FIRSTNAME AND LAST NAME of the user.

For Example :

My username is ranjith....so after log in... I should see complete name as Ranjith Reddy....as
Welcome Mr. Ranjith Reddy

So, my requirement is I want to display full name of the user using FirstName and Last Name using Label.


Please help. Thanks in ADVANCE.
Posted
Comments
__TR__ 20-Nov-12 2:24am    
Concatenate the 2 columns in your query. Something like
SELECT FIRSTNAME + ' ' + LASTNAME AS [Name] FROM [YourTable]
csharpbd 20-Nov-12 2:27am    
Can you share your code where you want to show full name according to first name and last name?
Ranjith Reddy CSE 20-Nov-12 2:36am    
Sir, I want to show Full name in welcome page after the user log in...

In welcome page i have a label to display users full name

This is my login page code using session :

Session["UserName"] = TxtUserName.Text;
Session["Password"] = TxtPassword.Text;

In welcome page, I used code as

lbldisplay.text = session["UserName"].ToString();

This is perfect...

But i want to show full name with FIRST name and Last Name

as Ranjith Reddy
csharpbd 20-Nov-12 3:34am    
Thanks for share your code, see Solution 3 it's posted by me. If any question please asked me also if it's help you please accept this answer.

ASP.NET
<asp:label id="lblFullName" runat="server" xmlns:asp="#unknown"></asp:label>

C#
lblFullName.Text = user.FirstName + " " + user.LastName;
 
Share this answer
 
If your first name's id : lblFirstName;
second name's id: lblSecondName;
and your resulting label's id, where you display first name and second name together : lblFullName;

then solution is :

lblFullName.Text = lblFirstName.Text+ " " + lblSecondName.Text;
 
Share this answer
 
In your login page, after user login success select user first name and last name from database using user identity/username. Then create a new session variable named "FullName" and put your first name and last name. see code below maybe code like that.
Code:
C#
//In your login pages write this code after login success.
string SQLSelect="Select FIRSTNAME,LASTNAME From TABLENAME Where USERNAME="+TxtUserName.Text;
//DataTable NameData=Execute your SQLSelect here
string FullName="Welcome "+NameData.Rows[0]["FIRSTNAME"].ToString()+" "+NameData.Rows[0]["LASTNAME"].ToString();
Session["FullName"] = FullName;


C#
// In your welcome page write this code.
lbldisplay.text = session["FullName"].ToString();


Maybe it's help you.
 
Share this answer
 
Comments
prasanna.raj 14-Mar-14 5:34am    
what is NameData here....
csharpbd 14-Mar-14 7:41am    
//DataTable NameData=Execute your SQLSelect here
Assign first name and last name to full name after valid logged in.
Don't assign user name to resulting lable.
Follow below code.
C#
string FullName="Welcome "+NameData.Rows[0]["FIRSTNAME"].ToString()+" "+NameData.Rows[0]["LASTNAME"].ToString();
Session["FullName"] = FullName;
 
Share this answer
 
Dear
you take a label in .aspx page and suppose its id =label1
then you on page 2 load get user first name and last name from database and use it
as
label1.text=first name+" "+last name;
 
Share this answer
 
As you are using Sessions to store your credentials ie.Uname and Password.So after successful login you will be redirected to welcome page with your session variables,so use those session variables to fire a query and store data to string variable using anr Connected/Disconnected architecture of ADO.NET.
C#
string lastName="Select LASTNAME From TABLENAME Where USERNAME='"+Session["UserName"].ToString()'"+" and Password='"+Session["Password"].ToString()+"'";
then write....
lbldisplay.text = Session["UserName"].ToString()+ lastName; 


 
Share this answer
 

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