Get membership all users name in asp.net
.Net framework Membership.GetAllUsers() method allow us to get a collection of all the users in the database.
Membership class GetAllUsers() method exists in System.Web.Security namespace.
GetAllUesrs() method return value type is System.Web.Security.MembershipUserCollection. this return value is a MembershipUserCollection of MembershipUser objects representing all of the users in the database.
in the bellow example code, we get the collection of all membership users and data bind this collection with a ListBox server control. if the collection is large then this method degrade the performance of asp.net application.
Membership.GetAllUsers(Int32, Int32, Int32) overloaded method allow us to get a collection of all the users in the database in pages of data. this overloaded method provide paging support of membership users list.
the following asp.net c# example code demonstrate us how can we get all the membership users in database programmatically at run time in an asp.net application.
GetAllUesrs() method return value type is System.Web.Security.MembershipUserCollection. this return value is a MembershipUserCollection of MembershipUser objects representing all of the users in the database.
in the bellow example code, we get the collection of all membership users and data bind this collection with a ListBox server control. if the collection is large then this method degrade the performance of asp.net application.
Membership.GetAllUsers(Int32, Int32, Int32) overloaded method allow us to get a collection of all the users in the database in pages of data. this overloaded method provide paging support of membership users list.
the following asp.net c# example code demonstrate us how can we get all the membership users in database programmatically at run time in an asp.net application.
GetAllUsersExample.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e) {
ListBox1.DataSource = Membership.GetAllUsers();
ListBox1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>GetAllUsers method example: how to get user list in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>GetAllUsers Method Example</h2>
<asp:Label ID="Label1" runat="server" Text="All Users" AssociatedControlID="ListBox1"></asp:Label>
<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Get All Users" OnClick="Button1_Click" />
</div>
</form>
</body>
</html>
- How to create user in asp.net
- How to create Login page in asp.net
- How to show login name in asp.net
- How to show login status in asp.net
- How to login users programmatically in asp.net
- How to get number of users online in asp.net
- How to change password in asp.net
- How to use LoggedInTemplate and AnonymousTemplate in LoginView control
- How to delete user in asp.net
- How to create a role programmatically in asp.net
- How to delete a role programmatically in asp.net
- How to get all the users in a role programmatically
- How to programmatically add user to role in asp.net