[英]Sharepoint 2007 multiple configurable web parts on same page
我在開發可配置且可以在一個站點上放置多次的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");
}
}
使用此代碼,每個站點只能放置此WebPart一次。
我曾嘗試將WebPartStorage
更改為Personal
,但並沒有幫助。
當我從類中刪除[XmlRoot(Namespace = "TestWebPart")]
時,可以多次放置它,但沒有可配置的屬性。
你知道如何處理嗎?
請嘗試以下操作:
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文件而不是.webpart文件並進行部署的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.