Dot Net Mafia

Group site for developer blogs dealing with (usually) Ionic, .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog



Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for Ionic, SharePoint, and Office 365.

Writing to the Property Bag using CAML in SP2010

There are a number of feature improvements in SharePoint 2010.  They have made many changes which allow you to do more with features when they are activated or upgraded.  One of the new features it the ability to write to the property bag.  To do this we just make use of the new PropertyBag element in your elements.xml file.  Here is what a file might look like that writes to the property bag.  As usual, I’ll point out that features or syntax could change.

<Elements xmnlns="">

  <PropertyBag ParentType="Web">

    <Property Name="MyCustomProperty1" Value="some value" />

    <Property Name="MyCustomProperty2" Value="4" />



I will point out that whatever type you initialize the property with, it will become semi-permanent.  Currently, this applies for integers and date/time.  If you try to save another type in an existing property later, you will end up with a null value being stored. This will save me some time in the future as I have had to write code to do this in the past.



Twitter Trackbacks for Writing to the Property Bag using CAML in SP2010 - Corey Roth - - Tip of the Day [] on said:

Pingback from  Twitter Trackbacks for                 Writing to the Property Bag using CAML in SP2010 - Corey Roth - - Tip of the Day         []        on

October 20, 2009 3:35 PM

Eran said:

I wrote a propertyBag to the elements.xml of a webPart.

but i can't find it in the code.

i use that line inside the code:

control.Path = SPContext.Current.Web.Properties["XmlPath"];

and that line in the elements.xml file:

<PropertyBag ParentType="Web">

   <Property Name="XmlPath" Type="string" Value="c:\Users\tag6k\Desktop\engStat.xml"></Property>


May 23, 2011 12:37 AM

Leave a Comment


About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2018 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems