Building the Membership List page

Learning Resources
 

Building the Membership List page


Membership.GetAllUsers() returns a MembershipUserCollection, which you can use to access individual MembershipUser. Example:

MembershipUserCollection users = Membership.GetAllUsers();
string email = users["some_username"].Email;

You can also retrieve ProfileInfo in the similar way:

ProfileInfoCollection profiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All);
DateTime lastActivity = profiles["some_username"].LastActivityDate;

However there are no FirstName and LastName properties by default, unless you manually specified them in your profile provider.
 

Anonymous users will see a generic message that invites them to log in. Logged-in users will see a message that welcomes them by their user name.

To customize the display for logged-in users

  • Switch to or open the Default.aspx page and switch to Design view.
  • From the Login group of the Toolbox, drag a LoginView control onto the page. The LoginView control is displayed with its AnonymousTemplate template open. This template allows you to define the content that users will see before they log in.
  • Click the edit area of the LoginView control to activate editing.
  • In the edit area of the LoginView control's AnonymousTemplate template, enter You are not logged in. Click the Login link to sign in.

It might be easier to copy the text and paste it into the edit area or add the text as markup in Source view than entering the text directly into the edit area. The following example shows how the text appears in markup.


 
  You are not logged in. Click the Login link to sign in.
  
 

  • In Design view, select the LoginView control, and then on the LoginView Tasks panel, in the Views list, click LoggedInTemplate. If you do not see the LoginView Tasks panel, right-click the heading of the LoginView control and then click Show Smart Tag. The LoggedInTemplate defines the content that will be displayed to users who have logged in.
  • Click the edit area of the LoginView control to activate editing and then enter the following text: You are logged in. Welcome,
  • Place the cursor in the edit area of the LoggedInTemplate after the text you just added. From the Login group of the Toolbox, double-click the LoginName control. The LoginName control displays the name of the user who is logged in.
  • From the Login group of the Toolbox, drag a LoginStatus control into the page. The LoginStatus control displays a Login link when the user is not logged in. When the user is logged in, the control displays a Logout hyperlink.
  • Save the page.

 

 For Support