的ProfileCommon可能找不到 [英] ProfileCommon could be not found

查看:111
本文介绍了的ProfileCommon可能找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了错误的ProfileCommon可能没有发现,在我的code。我不知道如何解决这个错误。我把空间利用system.Web.Profile,但错误仍然在这里所做的。可能有人帮助该怎么做?请帮我,如果你知道。谢谢

 公共部分类用户配置:System.Web.UI.UserControl
{
    私人字符串_username =;
    公共字符串用户名
    {
        {返回_username; }        集合{_username =价值; }
    }    保护无效Page_Init(对象发件人,EventArgs的发送)
    {
        this.Page.RegisterRequiresControlState(本);
    }    保护覆盖无效LoadControlState的(对象savedState)
    {
        [对象] ctlState =(对象[])savedState;
        base.LoadControlState(ctlState [0]);
        _username =(字符串)ctlState [1];
    }    保护覆盖对象SaveControlState()
    {
        [对象] ctlState =新对象[2];
        ctlState [0] = base.SaveControlState();
        ctlState [1] = _username;
        返回ctlState;
    }    保护无效的Page_Load(对象发件人,EventArgs的发送)
    {
        如果(!this.IsPostBack)
        {
            //如果用户名属性包含字符串emtpy,检索配置文件
            //当前用户,否则为指定的用户
            的ProfileCommon轮廓= this.Profile;
            如果(this.UserName.Length大于0)
                简介= this.Profile.GetProfile(this.UserName);
            txtFirstName.Text = profile.FirstName;
            txtLastName.Text = profile.LastName;
            ddlGenders.SelectedValue = profile.Gender;
            如果(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;
            txtPostal code.Text = profile.Address.Postal code;
            txtState.Text = profile.Address.State;
            txtPhone.Text = profile.Contacts.Phone;
            txtFax.Text = profile.Contacts.Fax;
        }
    }
    公共无效保存()
    {
        //如果用户名属性包含字符串emtpy,保存在当前用户的
        //轮廓,othwerwise保存配置文件指定用户
        的ProfileCommon轮廓= this.Profile;
        如果(this.UserName.Length大于0)
            简介= this.Profile.GetProfile(this.UserName);
        profile.FirstName = txtFirstName.Text;
        profile.LastName = txtLastName.Text;
        profile.Gender = ddlGenders.SelectedValue;
        如果(txtBirthDate.Text.Trim()长度方式> 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.Postal code = txtPostal code.Text;
        profile.Address.State = txtState.Text;
        profile.Contacts.Phone = txtPhone.Text;
        profile.Contacts.Fax = txtFax.Text;
        profile.Save();
    }}


解决方案

正如马克指​​出,型材只工作外的开箱即用的网站模板,我已经在博客上如何使用插件的说明方便使用配置文件为Web应用程序项目:

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

有可能自己做,这里是一个完全实现的工作,您可以下载:

http://leedumond.com/blog/asp -net-轮廓式的Web应用程序项目/

I got error ProfileCommon could be not found , in my code. I don't know how to fix the error. I put namespace using system.Web.Profile, but error still does here. Could someone help how to do that? Please help me if you know. Thank you

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();
    }

}

解决方案

As Mark pointed out, profiles only work out-of-the-box with the website template and I have blogged instructions on how to use the plug-in to facilitate the use of profiles for the Web Application project:

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

It is possible to do it yourself, and here's a fully working implementation that you can download:

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

这篇关于的ProfileCommon可能找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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