Some time we need to count the online users If you are new to ASP.net Membership provider, please refer http://www.revenmerchantservices.com/page/ASpnet-20-step-by-step-Membership-Provider-.aspx Below code will count online users C# Code MembershipUserCollection uc = Membership.GetAllUsers(); int count=0; foreach(MembershipUser u in uc) { if(u.IsOnline) count++; } VB Code Dim uc As MembershipUserCollection = Membership.GetAllUsers() Dim count As Integer = 0 For Each u As MembershipUser In uc If u.IsOnline Then count += 1 End If Next You can bind the online user names to ListBox using below code C# code System.Collections.Generic.List<string> lstUser = new System.Collections.Generic.List<string>(); MembershipUserCollection uc = Membership.GetAllUsers(); foreach (MembershipUser u in uc) { if (u.IsOnline) lstUser.Add(u.UserName); } ListBox1.DataSource = lstUser; ListBox1.DataBind(); VB code System.Collections.Generic.List<string> lstUser = new System.Collections.Generic.List<string>(); MembershipUserCollection uc = Membership.GetAllUsers(); foreach (MembershipUser u in uc) { if (u.IsOnline) lstUser.Add(u.UserName); } ListBox1.DataSource = lstUser; ListBox1.DataBind(); Satalaj
int count=0; foreach(MembershipUser u in uc) { if(u.IsOnline) count++; }
VB Code
MembershipUserCollection uc = Membership.GetAllUsers(); foreach (MembershipUser u in uc) { if (u.IsOnline) lstUser.Add(u.UserName);
}
ListBox1.DataSource = lstUser; ListBox1.DataBind();
VB code
Satalaj
Currently rated 5.0 by 2 people
I'm Satalaj.
↑ Grab this Headline Animator
Get notified when a new post is published.