Click here to Skip to main content
15,881,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi all

i want to show username on header section of masterpage, like

look at that your name on this website at top-right.
Posted

In login button click maintain the name of user in session.
in master page load write below code
if(session["Username"]!=null)
   lblname.text=session["Username"].tostring();


[AJ]
I would prefer using session variables as properties. Please create some properties for getting/setting session["Username"] instead of directly accessing it, which will increase the readability or maintainability. Either you can create a property in the same class or can use a common SessionHelper class.
 
Share this answer
 
v4
Comments
[no name] 28-Sep-11 7:19am    
not got it...

and assign the username in session to label text property
P.Salini 28-Sep-11 7:31am    
I have updated the solution
once try it and then tell me if any problem occurs
 
Share this answer
 
To display a username,this means that you are using membership on your website.So my advice is to add a login view,and put inside it loginname control.
 
Share this answer
 
i think you have to add a user control names it as header and put your name in that
and drag that user control on your page...

if you talking about the logged in name then just put login view control from the toolbox... :)
 
Share this answer
 
you try this code in master page...it shows top right your page.

XML
<div id="topContent" style="height: 65px">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Italic="True" Font-Size="Large"Style="z-index: 101; left: 1371px; position: absolute; top: 14px"></asp:Label>
</div>
 
Share this answer
 
v6

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