Monday, September 02, 2013

Removing SPWeb Property Value

Removing the Property Bag in the SharePoint 2010 is just little bit tricky.When I started to update the SPWeb object's property's properties.Remove and Update won't work. You need to set your Property Bag's value null before remove and update method called. Another important point is you have to call the remove method of AllProperties collection of SPWeb Object in SharePoint Object Model. It was different when I tested it with Power Shell Script in there I don't want to set the value null. Adding value to Property bag
web.Properties.Add("SomeValue", "900");
Removing the value and PropertyBag from the SPWeb's PropertyCollection.
web.Properties["SomeValue"] = null; // This is mandatory
Its something like we can't remove the directory from the DOS command until we delete all of its files.