User/group property type

Magnus Rahl
Member since: 2008
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
  • fredrik.haglund
    Member since: 2007

    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;

    #26972 Jan 12, 2009 11:50
  • Magnus Rahl
    Member since: 2008
    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