如何从另一个SharePoint页面访问元数据?通过Web部件?我不想使用任何类型的列表。
我看了一下this blog post,但我似乎无法弄明白。
以下代码是否相关?
<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">
<PublishingWebControls:RichHtmlField id="PageContent" FieldName="PublishingPageContent" DisableInputFieldLabel="true" runat="server"/>
</asp:Content>
答案 0 :(得分:0)
不要将共享信息存储在页面中,最好将元数据存储在PropertyBag中。
您有不同的存储属性范围:
示例来自: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)
{
}
});