Try our conversational search powered by Generative AI!

User/group property type

Vote:
 
I need a property type to hold a selected group. In 4.62 I modified the PropertySid type to hold a group instead of a user, but in CMS there is no property type for neither users nor groups. Has anyone created a custom property type for any of these uses?
#26968
Jan 12, 2009 9:10
Vote:
 

Yes, as long as you have a limited amount of users/groups it is quite simple.

Easiest is to use the Visual Studio designer and base it on PropertyString and create a Property Control for it.

Change the generated stub for the Control class to inherit from PropertySelectControlBase and you will get a nice Combo Box.

Just override SetupEditControls() and populate the list with users Membership.GetAllUsers() or RoleProvider.GetAllRoles().

protected override void SetupEditControls() {
string username = ToString();
foreach (MembershipUser user in Membership.GetAllUsers())
{
if (user.IsApproved)
{
         ListItem item = new ListItem(user.UserName);
item.Selected = item.Value == username;
base.EditControl.Items.Add(item);
}
}
}

#26972
Jan 12, 2009 11:50
Vote:
 
Very simple, thank you! I was making it too diffucult, wanting to mimic the old popup-with-select-from-listbox style. I hardly think there will be too many groups to make the dropdownlist impractical, so your solution suits my needs perfectly.
#26975
Jan 12, 2009 12:01
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.