Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 31st, 2008, 01:56 PM
Authorized User
 
Join Date: Oct 2008
Location: , , .
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
Default How to store user name from LoginName control

Hi,

Is any one can show me a trick how to store a user name from LoginName control into a variable in C#?

What I like to be able to do is, after user sucessfully login and the browser load the default page, I would like to display a pop-up message "Welcome, UserName". So I will program this pop-up message in Page_Load().

Thanks for your help.

Reply With Quote
  #2 (permalink)  
Old November 1st, 2008, 04:40 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Instead of getting the name from the LoginName control, you should get it from the MembershipUser instead:
Code:
string userName = string.Empty;
MembershipUser myMembershipUser = Membership.GetUser();
if (myMembershipUser != null)
{
  erName = myMembershipUser.UserName;
}
If GetUser) returns a non-null value, the variable myMembershipUser then holds the currently logged in user which has a UserName property.

Hope this helps,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old November 3rd, 2008, 02:28 PM
Authorized User
 
Join Date: Oct 2008
Location: , , .
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thank you so much Imar:)

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to store information input by user in ........ vishnu108mishra ASP.NET 2.0 Professional 0 March 1st, 2008 12:26 AM
LoginName Control Steve Spicer ASP.NET 2.0 Professional 3 August 25th, 2007 11:16 AM
Create a new user using store procedure. vaidya_kaustubh BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 April 30th, 2007 07:40 AM
LoginName hcanales ASP.NET 1.x and 2.0 Application Design 1 July 26th, 2006 03:16 PM
Add Windows User control in Web User Control agarwalvidhu C# 0 March 30th, 2006 01:17 AM



All times are GMT -4. The time now is 09:51 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.