What is property bag in SharePoint 2010?
How do I retrieve values from a property bag and get/set the values using powershell?
|
What is property bag in SharePoint 2010? How do I retrieve values from a property bag and get/set the values using powershell? |
||||
|
|
Using c#:
|
||||
|
|
Property bag is basically properties attached on web site ,site collection , web application and farm level. You can check out the codeplex tool here for more understanding - http://pbs2010.codeplex.com/ You also have a list of cmdlets from Powershell for property bag - http://collab.rdacorp.com/2010/05/sharepoint-2010-property-bag-cmdlet.html |
|||
|
|
|
To interact with the PropertyBags in code you simply refer to the object's Propeties member. There are PropertyBags available for the SPFarm, SPWebApplication, SPSite, and SPWeb. To set a value: site.Properties["PropertyName"] = "foo"; To read a value: string myProperty= site.Properties["PropertyName"].ToString(); |
|||
|
|
|
Share-Point property bags provide an easy-to-use storage mechanism for any serializable configuration data. Below is the sample code:
We must ensure that any data we store in Property Bags is serializable. If you attempt to persist non-serializable types in property bags,the configuration database or the content database may get corrupted. So, it is recommended you use "Application Setting Manager" to store\retrieve values in property bags |
|||||||||||||
|
|
One of the uses of SharePoint Manager 2010 (http://spm.codeplex.com/) is to view and update the property bags. This is nice in that it doesn't require a feature deployed to the environment so I use either this or the pbs2010 feature that @Deepu Nair recommended. |
|||||
|