Thursday 31 January 2013

SPWeb.AllProperties and SPWeb.Properties with Sharepoint 2010


SPWeb.Properties is a StringDictionary, and doesn’t support casing for keys/values (everything gets converted to lowercase), while
SPWeb.AllProperties is a Hashtable, and supports a few other datatypes apart from strings (I believe ints and DateTimes are supported)
Instead of working directly with the SPWeb.Properties StringDictionary, SharePoint 2010 now provides four methods to manage properties:
  • SPWeb.GetProperty(Object key)
  • SPWeb.AddProperty(Object key, Object value)
  • SPWeb.SetProperty(Object key, Object value)
  • SPWeb.DeleteProperty(Object key)

Call SPWeb.Update() in order to persist the changes to the underlying database and AllProperties is no different, so don’t forget to do so.

No comments :

Post a Comment