How to create the Profile object of user??

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

  1. Jeff

    Jeff Guest

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

  2. 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;

    }

    "Jeff" wrote:

    > 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....???
    >
    >
    >
    >
     
    =?Utf-8?B?U2FlZWQgS3VkYWltYXRp?=, Oct 13, 2006
    #2
    1. Advertising

  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


    "Saeed Kudaimati" <> wrote in
    message news:...
    > 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;
    >
    > }
    >
    > "Jeff" wrote:
    >
    >> 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....???
    >>
    >>
    >>
    >>
     
    Jeff, Oct 13, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Qmhhc2thcg==?=
    Replies:
    1
    Views:
    562
    Bruce Barker
    Dec 10, 2005
  2. VB Programmer

    Question: Setting Profile for create new user

    VB Programmer, Jan 16, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    505
    VB Programmer
    Jan 17, 2006
  3. Brad
    Replies:
    1
    Views:
    1,176
    Roedy Green
    Jul 19, 2005
  4. Andy B
    Replies:
    0
    Views:
    555
    Andy B
    May 3, 2008
  5. Steven
    Replies:
    5
    Views:
    513
    Steven
    Oct 24, 2008
Loading...

Share This Page