I’m working with asp.net member profiles. I can create the profile and retrieve values, but I can’t seem to set property values.
I am using the following code:
var profile = MemberProfile.GetUserProfile();
profile.fullName = tbFullName.Text;
profile.country = tbCountry.Text;
profile.city = tbCity.Text;
profile.streetAddress = tbStreeAddress.Text;
profile.phoneNumber = tbPhoneNumber.Text;
profile.Save();
And this is not updating the profile.
I also looked up several solutions in the internet, but nothing seems to work.
The profile class looks like this:
public class MemberProfile : ProfileBase
{
public static MemberProfile GetUserProfile(string username)
{
return (MemberProfile)Create(username);
}
public static MemberProfile GetUserProfile()
{
return (MemberProfile)Create(System.Web.Security.Membership.GetUser().UserName);
}
[SettingsAllowAnonymous(false)]
public string AuthGuid
{
get
{
var o = base.GetPropertyValue("auth_guid");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("auth_guid", value);
}
}
[SettingsAllowAnonymous(false)]
public string fullName
{
get
{
var o = base.GetPropertyValue("fullName");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("fullName", value);
}
}
[SettingsAllowAnonymous(false)]
public string country
{
get
{
var o = base.GetPropertyValue("country");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("country", value);
}
}
[SettingsAllowAnonymous(false)]
public string city
{
get
{
var o = base.GetPropertyValue("city");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("city", value);
}
}
[SettingsAllowAnonymous(false)]
public string streetAddress
{
get
{
var o = base.GetPropertyValue("streetAddress");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("streetAddress", value);
}
}
[SettingsAllowAnonymous(false)]
public string phoneNumber
{
get
{
var o = base.GetPropertyValue("phoneNumber");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("phoneNumber", value);
}
}
}
Thank you!
I ended up using a pre-built usercontrol someone else wrote on the Umbraco community site.
http://umbracoprofileeditor.codeplex.com/