Property Bag in Share Point
Allows storing configuration settings at
different levels of SP hierarchy outside of the application itself.
· a hash table of key value pair
· Available since SharePoint Services 3.0, SP2010 and SP2013.
· This is something like as how we will store values in AppSettings of web.config file.
· This information could be anything like connection strings, server names, file paths .
· We can encrypt the property bag value
· We can access Property Bag from CA or site settings
· We can Import and export Property Bags
Property Bags can be
created/modified/Deleted from SP Designer, using object model.
NOTE: SP Provides UI to access
the Property Bag settings. But in SP Foundation we need to set the property bag
configuration through programmatically only.
SP Provides Property Bags to
store and retrieve Config values at
following levels.
1)
Farm Level
2)
Web Application Level
3)
Site Collection Level
4)
List Level
5)
Item Level
//set Property Bag value
using (SPSite oSIte = new
SPSite(siteId))
{
using (SPWeb oWeb =
oSIte.OpenWeb(webId))
{
oWeb.AllowUnsafeUpdates=true;
oWeb.Properties["PropName1"]
= Value1;
oWeb.Properties["PropertyName2"] =
Value2;
oWeb.Properties.update();
oWeb.AllowUnsafeUpdates=false;
}
}
//access property bag value.
using (SPSite oSIte = new
SPSite(siteId))
{
using (SPWeb oWeb =
oSIte.OpenWeb(webId))
{
String
propName= oWeb.Properties["PropName1"];
}
}
NOTE: There is no out of box settings available for setting and reading the property bag value.You can download this Property Bag tool from the following link http://pbs2010.codeplex.com/
NOTE: There is no out of box settings available for setting and reading the property bag value.You can download this Property Bag tool from the following link http://pbs2010.codeplex.com/
0 comments:
Post a Comment