用户如何查看其他用户的个人资料信息? [英] How can a user view profile info of other users?

查看:457
本文介绍了用户如何查看其他用户的个人资料信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用此代码存储了个人资料信息

I have stored profile info using this code

        ProfileBase userprofile = HttpContext.Current.Profile;
        userprofile.SetPropertyValue("FirstName", TextBoxFirstName.Text);
        userprofile.SetPropertyValue("LastName", TextBoxLastName.Text);
        userprofile.SetPropertyValue("AboutMe", TextBoxAboutMe.Text);
        userprofile.SetPropertyValue("ContactNo", TextBoxContactNo.Text);

和在web.config中

and in web.config

<profile enabled="true"  defaultProvider="AspNetSqlProfileProvider">
  <properties>
    <add name="FirstName" type="String"  />
    <add name="LastName" type="String" />
    <add name="AboutMe" type="String" />
    <add name="ContactNo" type="String" />

  </properties>
</profile>

个人资料信息已存储,每个用户都可以使用类似的内容查看自己的个人资料信息

The profile info is stored and every user is able to view his own profile info using something like this

TextBoxFirstName.Text = HttpContext.Current.Profile.GetPropertyValue("FirstName").ToString();

如何获取其他用户的个人资料信息,例如某个用户在文本框中键入其他用户的用户名并单击一个按钮?

How to fetch profile info of other user say a user types the username of other user in a text box and clicks a button?

推荐答案

我在下面看到的是它获取指定用户的所有配置文件.

What I was looking is this below, it fetches all the profiles of the specified user.

ProfileInfoCollection pic = System.Web.Profile.ProfileManager.FindProfilesByUserName(ProfileAuthenticationOption.All, "username");
        foreach (ProfileInfo pi2 in pic)
        {
            //ProfileBase.Create(pi2.UserName).GetPropertyValue("FirstName").ToString();

            ListBox1.Items.Add(ProfileBase.Create(pi2.UserName).GetPropertyValue("FirstName").ToString());

            //(new ProfileBase) Create(pi2.UserName)).GetPropertyValue("FirstName");
        }

Hojo的回答非常有帮助,谢谢.

Answer by Hojo has been very helpful, thanks.

这篇关于用户如何查看其他用户的个人资料信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆