Reza on blogging [MVP]

THIS BLOG HAS MOVED TO: http://blogs.devhorizon.com/reza

Subscriptions

<March 2010>
SuMoTuWeThFrSa
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

News



toronto.sharepoint.camp


Navigation

Post Categories

Other Bloggers

Personal Links

Working with property bags

1) Definitely make sure that you call update method when you are done adding property bags, otherwise your changes won't be applied.

curWeb = SPContext.Current.Web;
curWeb.Properties.Add("MyProperty", DateTime.Now.ToString());
curWeb.Properties.Update();
 
2) In some cases I have found that SPWeb.Properties.Remove("MyProperty") does not work even if you call update method after. In those case when I set the property value to null , it will be removed from the collection and SPWeb.Properties.ConstainsKey("MyProperty") does not return “True” which means it is not there.

curWeb = SPContext.Current.Web;
curWeb.Properties["MyProperty"]= null;
curWeb.Properties.Update();

To find out if a property bag exists or not simply check this:

if (curWeb.Properties["MyProperty"] != null)
 {
  //Exists
 }
else
 {
  // Does not Exist
 }


posted on Wednesday, July 25, 2007 4:15 PM by rezaa

Powered by Community Server, by Telligent Systems