How to create the Profile object of user??

Discussion in 'ASP .Net' started by Jeff, Oct 13, 2006.

  1. Jeff

    Jeff Guest


    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....???
    Jeff, Oct 13, 2006
    1. Advertisements

  2. Jeff

    Guest Guest

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

    List<MembershipUserWrapperForMP> memberList = new

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

    Guest, Oct 13, 2006
    1. Advertisements

  3. Jeff

    Jeff Guest

    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
    Jeff, Oct 13, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.