Friday, July 13, 2012
SharePoint Property Bag
How to Add new item to property bag
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("siteUrl"))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
web.AllProperties.Add("key", "value");
web.Update();
web.AllowUnsafeUpdates = false;
}
}
});
How to Read property from property bag
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("siteUrl"))
{
using (SPWeb web = site.OpenWeb())
{
if (web.AllProperties.ContainsKey("key"))
{
MessageBox.Show(web.Properties["key"].ToString());
}
}
}
});
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment