How to create the Profile object of user??

J

Jeff

Hey

ASP.NET 2.0

I'm developing a web portal where users must login to. As far as I know all
users are accessible from the MembershipUserCollection. I know that current
user is also accessible via the Profile object in the webpage, but I want to
access the properties of one of the other users. So I guess I have to create
an instance of the ProfileCommon class... I have the username of the user I
want to create a ProfileCommon object of, but my problem is that I don't
know how to it....???
 
G

Guest

You can use this code:
public List<MembershipUserWrapperForMP> GetMembers(string usernameToFind)
{

List<MembershipUserWrapperForMP> memberList = new
List<MembershipUserWrapperForMP>();

if (usernameToFind != null)
{
MembershipUser mu = Membership.GetUser(usernameToFind);
if (mu != null)
{
MembershipUserWrapperForMP md = new
MembershipUserWrapperForMP(mu);
ProfileCommon pc =
(ProfileCommon)ProfileBase.Create(mu.UserName, true);
md.FirstName = pc.FirstName;
md.LastName = pc.LastName;
memberList.Add(md);
}
}
return memberList;

}
 
J

Jeff

Thanks for the tip!

This was about getting the profile of a different user, this code get the
profile of a different user:
ProfileCommon userProfile =
(ProfileCommon)System.Web.Profile.ProfileBase.Create("username", true);

I'm posting this reply in case somebody else came accross the same problem

Thanks for your tip Saeed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top