Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
how to concat first name and last name and display in label in asp.net C#
-------------------------------------------------------------------------
 

hi friends my project is based on asp.net c#.
 
while registering to this website user will enter his first name and last name in Registration form.
 
I want to store this in session.
like session["username"]
 
so this will display with label like
 
Hi, Ubaid Rahman
 

Please help thank u.
Posted 27-Jan-13 5:12am
Comments
Richard MacCutchan at 27-Jan-13 11:27am
   
This can be achieved by standard string concatenation.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try:
Session["username"] = firstName + " " + lastName;
...
myLabel.Text = string.Format("Hi, {0}", Session["username"]);
  Permalink  
Comments
ridoy at 27-Jan-13 13:19pm
   
+5
AshishChaudha at 27-Jan-13 23:18pm
   
my +5
Renju Vinod at 28-Jan-13 0:58am
   
+5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

try this
 
        Session["username"] = s3 = string.Format("{0} {1}", firstname, lastname);
        Label1.Text = Session["username"];
        
Thanks
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

HI,
 
As mentioned in the above solution you can concatenate and there is another way to concatenate also.
 
    Session["username"] = string.Concat(firstName , lastName);
    myLabel.Text = Session["username"];
 
For reference follow the following link:
C# string.Concat
What's the best string concatenation method using C#?
 
Thanks
  Permalink  
Comments
AshishChaudha at 27-Jan-13 23:19pm
   
my 5+
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Hello,
 
Might be it's helpful...
 
Session["username"] = "Hi!!" + firstname + lastname ;
Label1.Text = convert.tostring(Session["username"]);
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid