【问题标题】:Persisting sharepoint EditorPart settings持久化 sharepoint EditorPart 设置
【发布时间】:2011-10-13 03:42:40
【问题描述】:

System.Web.UI.WebControls.WebParts.EditorPart 类继承,我已经看到可以在 VisualWebPart 中公开一个公共属性,当通过 EditorPart 更新时,该属性将自动保存在 sharepoint 中。

我遇到的问题是保存字符串和整数效果很好,但是当我尝试保持集合的值时,例如 List<String> 对象没有保存。

代码如下所示。

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

有人愿意提供一些见解吗?你只能使用这种技术保存基元吗?

【问题讨论】:

    标签: .net vb.net sharepoint sharepoint-2010 web-parts


    【解决方案1】:

    你是对的,web part默认只能将原始类型保存到个性化存储中。

    您必须将复杂类型序列化为保存,然后保存到 Web 部件中

    您必须为复杂类型编写类型转换器,并在 Web 部件中将该类型转换器指定为属性。

    【讨论】:

      猜你喜欢
      • 2012-04-05
      • 2014-07-06
      • 2011-11-20
      • 1970-01-01
      • 2019-10-30
      • 1970-01-01
      • 1970-01-01
      • 2021-05-29
      • 1970-01-01
      相关资源
      最近更新 更多