Adding personalized data for a new user upon registration.

Hello, I am trying to store personalized data for new users using a registration page which inherits for the personalsettings page (episerver samples). Does anyone have a sample on how to do this? I know that if an aready existing user is logged in, they can change values using the following code: if(PersonalizedData.Current!=null) { // Print current value if(PersonalizedData.Current["MyTestKey",CurrentPage.PageLink]!=null) Response.Write(PersonalizedData.Current["MyTestKey",CurrentPage.PageLink]); The question is how to do it for the new users. The Registration page creates a new user but I am not sure how to apply it to the code above. The code for creating the user is: User = new UserSid(SecurityIdentityType.ExtranetUser); Thanks. Victor
Feb 14, 2008 12:20
The following was sent to me by EPiServer (Greger). Hi Victor I just tested the following code without any problems. Can’t really say why it won’t work for you. Perhaps if you send me the whole aspx/ascx I might find something. By the way, are you sure you want to store information regarind city etc per page (using Current[“key”,pagereference])? .aspx     Global
.cs protected void Page_Load(object sender, System.EventArgs e)                                                           {             if (!IsPostBack)             {                 if (PersonalizedData.Current["cbGlobal"] != null)                     cbGlobal.Checked = (bool)PersonalizedData.Current["cbGlobal"];                 if (PersonalizedData.Current["cbLocal", CurrentPageLink] != null)                     cbLocal.Checked = (bool)PersonalizedData.Current["cbLocal", CurrentPageLink];                 if (PersonalizedData.Current["tbGlobal"] != null)                     tbGlobal.Text = PersonalizedData.Current["tbGlobal"].ToString();                 if (PersonalizedData.Current["tbLocal", CurrentPageLink] != null)                     tbLocal.Text = PersonalizedData.Current["tbLocal", CurrentPageLink].ToString();             }                                                           }         protected void save(object sender, System.EventArgs e)         {             PersonalizedData.Current["cbGlobal"] = cbGlobal.Checked;             PersonalizedData.Current["cbLocal", CurrentPageLink] = cbLocal.Checked;             PersonalizedData.Current["tbGlobal"] = tbGlobal.Text;             PersonalizedData.Current["tbLocal", CurrentPageLink] = tbLocal.Text;         }
Feb 20, 2008 9:16
I am still struggling with this code. I've explored both options of using the CreateUserWizard or add a personalizedData. It seems that I am closer to finding a solution with personalizedData but I am struggling with one small aspect. When logged in, I am able to change the personalized data with no problem (using PersonalSettings control). However, when I am creating a new user after the user fills out the registration form (Registration control), I get the core values recorded for the user (user name, name, lastname) but not the PersonalizedData (City). The simple PersonalizedData.Current["City"] = City.Text; doesn't work as there is no current value for the user. I tried the following but it doesn't work. User = new UserSid(SecurityIdentityType.ExtranetUser); PersonalizedData userData = PersonalizedData.Load(User.Name); userData["City"] = City.Text; I don't get any errors but the values are not recorded in the tblUserProperty table. What am I missing in the Register control to register this personal data for the new user?
Feb 20, 2008 14:18
Hi Victor! In case you havent figured this out yet, I guess you simply miss the final Save() call: PersonalizedData persData = PersonalizedData.Load(username); persData["City"] = "Stockholm"; persData.Save(); Regards, Johan Olofsson
Mar 04, 2008 10:19
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.