0

I develop web part with custom editor part and faced with this question.
Is it possible in web part set Personalizable attribute to generic List? For example I want something like this:

[WebBrowsable(false)]
[Personalizable(PersonalizationScope.Shared)]
 public List<AnnouncementItem> Announcements
 {
      get { return _announcements; }
      set { _announcements = value; }
 }

Is it possible, and what kind of types at all can be used as "Personalizable"?
Thanks.

Solution:
I use a custom EditorPart to select multiple lists using AssetUrlSelector, but I need a way to personalize this collection for end user.List<of custom objects> doesn't work, but I found that List<string> (and only string) work perfectly. So, I get required lists in EditorPart and pass their to the web part using List<string>.

Kai
  • 2,023
  • 7
  • 28
  • 49

2 Answers2

1

Try using a custom EditorPart to add/remove items from the collection. I've never built a web part that personalized a collection so I don't know if it works but I'd definitely try the collection with an EditorPart. If it doesn't work, serialize XML into a string property.

knight0323
  • 738
  • 2
  • 6
  • 12
0

Your question does not seem to match your code. Your code shows a collection of custom objects. I doubt an end user will be able to set such a property. To have a property that points to a generic list, you would probably be better off defining the property as a string that contains the URL to a list.

Rich Bennema
  • 10,295
  • 4
  • 37
  • 58