-1

如何从另一个 SharePoint 页面访问一个 SharePoint 页面的元数据?通过 Web 部件?我不想使用任何类型的列表。

我看过这篇博文,但我似乎仍然无法弄清楚。

以下代码是否相关?

<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">
    <PublishingWebControls:RichHtmlField id="PageContent" FieldName="PublishingPageContent" DisableInputFieldLabel="true" runat="server"/>
</asp:Content> 
4

1 回答 1

0

不要将共享信息存储在页面中,最好将元数据存储在 PropertyBag 中。

您有不同的 Scope 用于存储属性:

  • 农场
  • 项目清单
  • Web应用程序
  • 地点
  • 列表/库文件夹。

示例来自: http: //www.codeproject.com/Articles/43601/SharePoint-Property-Bag

SPSecurity.RunWithElevatedPrivileges(delegate()
        {
        try
        {
            using (SPSite RootSite = new SPSite(URL))
            {
                using (SPWeb SiteCollection = RootSite.OpenWeb())
                {                    
                    try
                    {
                        SiteCollection.AllowUnsafeUpdates = true;
                       // Get connection string from Property bag
                        if (SiteCollection.AllProperties.ContainsKey("ConnectionString"))
                        {
                            ConnectionString = SiteCollection.AllProperties["ConnectionString"].ToString();
                        }                        
                        // Set siteID in the Property bag
                        SiteCollection.Properties["siteID"] = siteID;
                        SiteCollection.Properties.Update();
                        SiteCollection.AllowUnsafeUpdates = false;                        
                    }
                    catch (Exception ex) 
                    { 
                      //Handle Exception  
                    }           
                }
            }
        }
        catch(Exception ex)        
        {            
        }
        });
于 2013-03-27T09:20:59.900 回答