DaniWeb IT Discussion Community

Code Snippets (http://www.daniweb.com/code/)
-   aspnet (http://www.daniweb.com/code/aspnet.html)
-   -   Working with ASP.Net 2.0 Membership Classes - Shalivn (http://www.daniweb.com/code/snippet834.html)

Shalvin aspnet syntax
Mar 2nd, 2008
Web site Administration Tool is accessible only from the hosting server. Many times programmers won't have direct access to the the hosting server. So knowledge of ASP.Net Membership classes is an added advantage in creating an administrative module for the site.
In this code snippet we will take up:
1. Listing all roles
2. Creating a role
3. Listing all users
4. Deleting a user
5. Listing Number of users online

  1. 1.
  2. lstRoles.DataSource = Roles.GetAllRoles();
  3. DataBind();
  4.  
  5. 2.
  6. Roles.CreateRole("Admin");
  7.  
  8. 3.
  9. lstUsers.DataSource = Membership.GetAllUsers();
  10. DataBind();
  11.  
  12. 4. Membership.DeleteUser("Anish");
  13.  
  14. 5.
  15. Mebership.GetNumberOfUsersOnline();