Inheriting from the System.Web.UI.WebControls.WebParts.EditorPart
class I have been shown that it is possible to expose a public property in your VisualWebPart that when updated through the EditorPart will be automagically persisted in sharepoint.
The problem I have run into is saving strings and integers works great but when I attempt to persist the value of a collection such as List<String>
the object is not saved.
The code looks like this.
Public Class MyCustomEditorPart
Inherits EditorPart
Public Overrides Function ApplyChanges() As Boolean
VisualWebPart1.TestString = "Test"
VisualWebPart1.TestList = new List(Of String) ''Add Items....
End Function
Public Overrides Sub SyncChanges()
Dim readString As String = VisualWebPart1.TestString ''Works great
Dim readList As List(Of String) = VisualWebPart1.TestList ''Always an empty new instance
End Function
End Class
Public Class VisualWebPart1
Inherits WebPart
Public Property TestString As String
Public Property TestList As List(Of String)
End Class
Anyone care to provide some insight? Can you only save primitives using this technique?