I added some custom fields to the user profile. One of them is a dropdown list and the other is a multi select (checkboxes) which I added values to for the "Choices" in those fields. I would like to show these values in the registration form view. How do I do this?
Hi Laura,
Please take a look to this KB article in order to achieve your goal:
Best regards
Hi Junior. Sadly, that article only shows how to add a custom text box field. I need to add a dropdown list and checkbox list that has the options filled from the values I entered in the custom field from the admin interface.
Hi Junior. Sadly, that article only shows how to add a custom text box field. I need to add a dropdown list and checkbox list that has the options filled from the values I entered in the custom field from the admin interface.
The code sample below is the way to set the values. For persisting the values in the database, it is needed to save the changes by using the UserProfileManager:
UserProfileManager profileManager = UserProfileManager.GetManager();
.......
profile.SetValue("Checkboxes", new string[] { "Option2" } );
......
profileManager.SaveChanges();
However, it is a good practice to execute the logic in the controller and keep the view only for displaying the value.
Here is a code sample to display the custom field values in the view after they have been set:
@foreach (var choice in Model.Item.Fields.Choices) //Choices is a custom ChoiceField added to a content type
{
<span>@choice.Text.ToString()</span> :
<span>@choice.PersistedValue.ToString()</span>
}
For more details, please check this KB article - knowledgebase.progress.com/.../mvc-how-to-display-custom-choicefield-s-selected-choices-using-razor