0

目前我有一个完整的工作注册表。但是我现在需要在表单上添加用户地址,一切都很好,直到我来添加用户地址信息

Dim newUser As New UserInfo
//Memebership and Userinfo added
newUser.Profile.PreferredLocale = Services.Localization.LocaleController.Instance.GetCurrentLocale(Me.PortalId).Code
newUser.Profile.SetProfileProperty("PostalCode", "S62 6EP")
newUser.Profile.City = txtCity.text
newUser.Profile.Country = txtCountry.text
newUser.Profile.Region = txtRegion.text
newUser.Profile.Street = txtstreet.text
newUser.Profile.Unit = unit.text

邮政编码不同的原因是一个测试,看看它是否改变了结果(它没有)

基本上,用户注册良好。但是,当我转到 UserProfile 页面时,数据不存在。只有名字和姓氏在字段中。

似乎在错误的 propertydefinitionID 下将数据添加到数据库(例如,preferedlocale 添加的 ID 为 19,但如果我在 UserProfile 页面中更改它,我得到 38

4

1 回答 1

2

这是我创建新用户的方式。


DotNetNuke.Entities.Users.UserInfo uInfo = new UserInfo();
uInfo.Username = txtEmail.Text.ToString();
uInfo.Membership.Password = txtPassWord.Text.ToString();
uInfo.PortalID = 0;//this should be appropriate portal id if you want to support multi portal registrations
uInfo.Email = txtEmail.Text.ToString();
DotNetNuke.Security.Membership.UserCreateStatus status = DotNetNuke.Entities.Users.UserController.CreateUser(ref uInfo);
if (status == DotNetNuke.Security.Membership.UserCreateStatus.Success)
{
     //TODO User Created Successfully - update your profile properties here

}
else
{
   //TODO Error Creating user s
   //something like lblError.Text = status.ToString();
}

因此,提示您为用户设置正确的门户 ID,并在完成设置属性后通过调用适当的函数来保存配置文件属性。

我希望这将有所帮助。

于 2010-11-19T07:51:16.147 回答