Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 31st, 2008, 01:56 PM
Authorized User
 
Join Date: Oct 2008
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.

 
Old November 1st, 2008, 04:40 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.
 
Old November 3rd, 2008, 02:28 PM
Authorized User
 
Join Date: Oct 2008
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thank you so much Imar:)






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.