找不到 ProfileCommon

2024-03-16

我在我的代码中收到错误 ProfileCommon 无法找到。我不知道如何修复该错误。我使用 system.Web.Profile 放置命名空间,但这里仍然出现错误。有人可以帮忙怎么做吗?如果您知道请帮助我。谢谢

public partial class UserProfile : System.Web.UI.UserControl
{
    private string _userName = "";
    public string UserName
    {
        get { return _userName; }

        set { _userName = value; }
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        this.Page.RegisterRequiresControlState(this);
    }

    protected override void LoadControlState(object savedState)
    {
        object[] ctlState = (object[])savedState;
        base.LoadControlState(ctlState[0]);
        _userName = (string)ctlState[1];
    }

    protected override object SaveControlState()
    {
        object[] ctlState = new object[2];
        ctlState[0] = base.SaveControlState();
        ctlState[1] = _userName;
        return ctlState;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            // if the UserName property contains an emtpy string, retrieve the profile
            // for the current user, otherwise for the specified user
            ProfileCommon profile = this.Profile;
            if (this.UserName.Length > 0)
                profile = this.Profile.GetProfile(this.UserName);
            txtFirstName.Text = profile.FirstName;
            txtLastName.Text = profile.LastName;
            ddlGenders.SelectedValue = profile.Gender;
            if (profile.BirthDate != DateTime.MinValue)
                txtBirthDate.Text = profile.BirthDate.ToShortDateString();
            ddlOccupations.SelectedValue = profile.Occupation;
            txtWebsite.Text = profile.Website;
            txtStreet.Text = profile.Address.Street;
            txtCity.Text = profile.Address.City;
            txtPostalCode.Text = profile.Address.PostalCode;
            txtState.Text = profile.Address.State;
            txtPhone.Text = profile.Contacts.Phone;
            txtFax.Text = profile.Contacts.Fax;
        }
    }
    public void Save()
    {
        // if the UserName property contains an emtpy string, save the current user's
        // profile, othwerwise save the profile for the specified user
        ProfileCommon profile = this.Profile;
        if (this.UserName.Length > 0)
            profile = this.Profile.GetProfile(this.UserName);
        profile.FirstName = txtFirstName.Text;
        profile.LastName = txtLastName.Text;
        profile.Gender = ddlGenders.SelectedValue;
        if (txtBirthDate.Text.Trim().Length > 0)
            profile.BirthDate = DateTime.Parse(txtBirthDate.Text);
        profile.Occupation = ddlOccupations.SelectedValue;
        profile.Website = txtWebsite.Text;
        profile.Address.Street = txtStreet.Text;
        profile.Address.City = txtCity.Text;
        profile.Address.PostalCode = txtPostalCode.Text;
        profile.Address.State = txtState.Text;
        profile.Contacts.Phone = txtPhone.Text;
        profile.Contacts.Fax = txtFax.Text;
        profile.Save();
    }

}

正如 Mark 指出的那样,配置文件只能与网站模板一起使用,并且我已经在博客中发布了有关如何使用插件以方便在 Web 应用程序项目中使用配置文件的说明:

http://www.codersbarn.com/post/2008/07/10/ASPNET-PayPal-Subscriptions-IPN.aspx http://www.codersbarn.com/post/2008/07/10/ASPNET-PayPal-Subscriptions-IPN.aspx

您可以自己完成此操作,您可以下载以下完整的工作实现:

http://leedumond.com/blog/asp-net-profiles-in-web-application-projects/ http://leedumond.com/blog/asp-net-profiles-in-web-application-projects/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

找不到 ProfileCommon 的相关文章

随机推荐

  • 定义一个不平凡的 Scala 案例类是否合适?

    我今天正在定义一个 Scala 类 我想 我需要一个equals方法和一个hashCode方法 和一个copy方法也会很方便 我将把它变成一个案例类 我的类已经有一堆其他代码 而且绝不是微不足道的 很好 一切都有效 但是当教科书处理案例类时
  • 获取Makefile中的源代码结构

    我正在开发一个 C 项目 我决定将源代码及其对象放在不同的目录中 根目录有类似这样的内容 SmartC tree L 1 built doc Makefile README md src tests trash 因此 在 src 和buil
  • Type.GetFields() - 只返回“public const”字段

    我想调用 Type GetFields 并且只返回声明为 public const 的字段 到目前为止我有这个 type GetFields BindingFlags Static BindingFlags Public 但这还包括 公共静
  • 访问不存在的缩略图

    我制作了一个应用程序 可以向您显示计算机中的文件列表 每当您单击列表中的任何项目时 它旁边的小图片框都会显示相应文件的缩略图 我在 Windows 7 上使用 C 为了获取缩略图 我重复使用了另一个问题中发布的方法 首先 我参考了 Wind
  • Swagger 参数和复杂类型

    在下面的 Swagger 定义中 我需要参数labelValue属于类型LabelValueObject 以便对其进行验证并正确反序列化 但是 我无法弄清楚语法 那怎么办呢 swagger 2 0 paths competition pos
  • Python 中的树实现

    如何在Python中实现树 我是Python初学者 给我一个大概的想法 Build a Node类 具有一些内容对象和子对象列表 它们又是Node
  • 使用 ACL 的 Redis Docker 镜像

    我正在尝试测试新的 Redis 6 ACL 配置 我想使用尽可能简单的配置来运行测试以熟悉配置 我的 Redis 将作为 Docker 容器运行 请考虑一下我是一个 Redis 新手 My Dockerfile FROM redis 6 2
  • “旧版”和“稳定版”有什么区别?

    我正在使用 JQuery Mobile 有两个可用版本 稳定版本和旧版本 我对后一种不太熟悉 什么是旧版本 或者说和稳定版有什么区别 生产现场推荐使用哪一种 非常感谢 遗留版本是旧的稳定版本 仍然可用 并且可能受支持 因为有人可能需要它 例
  • 在 angularJS2 项目中哪里放置/找到 systemjs.config.js 文件?

    我是 Angular 2 的新手 并尝试在我的项目中使用 ng2 datetime picker 现在 在安装 ng2 datetime picker 包后 当我运行该项目时 得到了404 错误指出未找到 ng2 datetime pick
  • GWT 中的 Java 8 支持

    这似乎是一个非常基本的问题 但我到处搜索 发现几乎没有任何地方提到它 所以 我就在这里问一下 目前在 GWT 中支持 Java 8 新语言结构的计划是什么 此外 提议的 Java 8 库的哪些子集将用于客户端模拟 流 API 新的日期 时间
  • 在 C/C++ 中解析二进制消息流

    我正在编写二进制协议 Javad GRIL 协议 的解码器 它由大约一百条消息组成 数据格式如下 struct MsgData uint8 t num float x y z uint8 t elevation 这些字段是 ANSI 编码的
  • 如何在运行时跳过单元测试?

    提前致谢 我们使用 selenium Web 驱动程序进行了一些自动化测试 这些测试非常棒 并且提供了非常好的回归包 问题是现在我们的代码中有功能切换 所以我需要说忽略这些测试 除非该功能切换已打开 关闭 我在谷歌上找不到任何真正的东西 理
  • 用 C 将文本文件中的数字读取到数组中

    我是一个编程菜鸟 所以请耐心等待 我正在尝试将文本文件中的数字读取到数组中 文本文件 somenumbers txt 仅包含 16 个数字 例如 5623125698541159 include
  • Laravel 5:在服务器环境上运行迁移,而不是在本地

    我在 Laravel 5 应用程序中创建了一组简单的数据库迁移 它们在我的本地开发环境中运行良好 现在是时候在我的新生产服务器环境上运行迁移了 我已经配置了数据库连接并部署了应用程序 并且应用程序可以看到数据库 但没有表 因此需要运行迁移
  • 使用分类数据作为 sklearn Logistic 回归中的特征

    我试图了解如何使用分类数据作为特征sklearn linear model s LogisticRegression 我当然知道我需要对其进行编码 我不明白的是如何将编码特征传递给逻辑回归 以便将其作为分类特征进行处理 而不是将其在编码为标
  • Vim swp 文件干扰存储库 vimdiff

    我的设置是使用 vim 特别是图形模式下的 MacVim 编辑源文件 然后使用 vimdiff 再次在图形模式下 进行 mercurial 存储库差异 有时 当我进行 diff 时 vim 会给出错误 交换文件 nn src imm mod
  • 将 SharedPreferences 传递给 doInBackground()

    我试图将 SharedPreferences 首选项作为参数传递给 AsyncTask 中的 doInBackground 函数 我已经将一个字符串 url 传递给它 所以我需要将首选项也作为字符串传递 我可以简单地使用 prefs toS
  • Python tkinter 通过单选按钮输入小部件状态切换

    一个简单的问题 对于像我这样的 tkinter 新手来说不是那么简单 我正在构建一个 GUI 我想要有两个单选按钮来驱动 Entry 小部件的状态 启用或禁用 用户将在其中输入数据 当按下第一个单选按钮时 我希望禁用该条目 当按下第二个单选
  • 春季侦探行李传播未传播/工作

    我们当前使用的是 sleuth 2 2 3 RELEASE 我们看不到 http 标头中传递的 userId 字段没有传播 下面是我们的代码 BaggageField REQUEST ID BaggageField create x vca
  • 找不到 ProfileCommon

    我在我的代码中收到错误 ProfileCommon 无法找到 我不知道如何修复该错误 我使用 system Web Profile 放置命名空间 但这里仍然出现错误 有人可以帮忙怎么做吗 如果您知道请帮助我 谢谢 public partia