Sharepoint 2007在同一页面上有多个可配置的web部件

本文关键字:配置 部件 web 2007 一页 Sharepoint | 更新日期: 2023-09-27 17:58:26

我在开发可配置且可以多次放置在一个网站上的webPart时遇到问题。

这是我的实际代码:

[XmlRoot(Namespace = "TestWebPart")]
public class TestWebPart : Microsoft.SharePoint.WebPartPages.WebPart
{
    public TestWebPart()
    {
        this.ExportMode = WebPartExportMode.All;
    }
    private string listName;
    // SharePoint setting with required attributes
    [Browsable(true),
     Category("List Config"),
     WebPartStorage(Storage.Shared),
     FriendlyName("List Name"),
     Description("Name of a list to get images")]
    public string ListName
    {
        get { return listName; }
        set { listName = value; }
    }
    protected override void Render(HtmlTextWriter writer)
    {
        writer.Write("test");
    }
}

使用此代码,我可以在每个网站上只放置此Web部件一次。

我尝试过将WebPartStorage更改为Personal,但没有帮助。

当我从类中删除[XmlRoot(Namespace = "TestWebPart")]时,它可以被多次放置,但没有可配置的属性。

你知道怎么处理吗?

Sharepoint 2007在同一页面上有多个可配置的web部件

尝试以下操作:

1) 删除[XmlRoot(Namespace = "TestWebPart")]行。

2) 从System.Web.UI.WebControls.WebParts.WebPart而不是Microsoft.SharePoint.WebPartPages.WebPart继承web部件。

3) 使用以下属性作为web部件属性:

   WebBrowsable(true), 
   Personalizable(PersonalizationScope.Shared), 
   SPWebCategoryName("List Config"), 
   WebDisplayName("List Name"),
   WebDescription("Name of a list to get images")

我已经修复了这个问题,创建.dwp文件而不是.webart文件并部署它。