I am new to DNN and I have to add custom fields(More questions ) to registration fields. User Info saving correctly in database and when saving answer in userprofile table I am getting error is Object reference not set to an instance of an object.
I have added answer1, answer2, answer3, answer4, answer5 in profilepropertydefinition table using manage profile properties link.
Please help me on this regard.
Below is the code I am trying
---Saving User Info
Dim oUserInfo As New UserInfo()
oUserInfo.Profile.InitialiseProfile(Me.PortalId)
oUserInfo.Membership.Username = txtPreferredUsername.Text
oUserInfo.Username = txtPreferredUsername.Text
oUserInfo.FirstName = txtFirstName.Text
oUserInfo.LastName = txtLastName.Text
oUserInfo.Membership.Email = txtEmailAddress.Text
oUserInfo.Email = txtEmailAddress.Text
oUserInfo.Membership.Approved = True
oUserInfo.Membership.Password = txtPassword.Text
UserController.CreateUser(oUserInfo)
---Saving questions in Userprofile table
Dim objUserController As New UserController
Dim objUserInfo As New UserInfo
objUserInfo = UserController.GetUserByName(Me.PortalId, oUserInfo.Username, False)
objUserInfo.Profile.SetProfileProperty("Answer1", txtAnswer1.Text)
objUserInfo.Profile.SetProfileProperty("Answer2", txtAnswer2.Text)
objUserInfo.Profile.SetProfileProperty("Answer3", txtAnswer3.Text)
objUserInfo.Profile.SetProfileProperty("Answer4", txtAnswer4.Text)
objUserInfo.Profile.SetProfileProperty("Answer5", txtAnswer5.Text)
UserController.UpdateUser(Me.PortalId, objUserInfo)
Thanks
Naveen