in

Dot Net Mafia

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

This Blog

Syndication

Archives

Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for SharePoint 2013, Office 365 / SharePoint Online and Visual Studio 2013.

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="http://schemas.microsoft.com/sharepoint/">

  <PropertyBag ParentType="Web">

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

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

  </PropertyBag>

</Elements>

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.

Comments

 

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

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

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>

 </PropertyBag>

May 23, 2011 12:37 AM

Leave a Comment

(required)  
(optional)
(required)  
Add

About CoreyRoth

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