从 SharePoint 的 Web 部件设置中获取属性

Get properties from SharePoint's web part settings

如何访问 Web 部件中的属性值?我想检索 "Category" 字段值,然后能够根据用户设置的类别过滤我的应用程序的内容。到目前为止,我只找到了有关如何添加自定义设置的信息,但还没有弄清楚如何使用 C# 检索它。

Webpart 属性不过是 Class 的属性,这里是一个字符串示例 属性 `

private string customProperty;
[WebBrowsable(true),
Category("Custom Properties"),
WebDisplayName("CustomProperty"),
WebDescription("CustomProperty Description"),
Personalizable(PersonalizationScope.Shared)]
public string CustomProperty
{
    get { return customProperty; }
    set { customProperty = value; }
}

在这里您可以使用 this.CustomProperty

访问 属性

在您的场景中,它将是一个会导致下拉列表的枚举,您也可以使用相同的方式 this.{Your Property Name} 访问它。