Reza on blogging [MVP]

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

Subscriptions

<February 2012>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
26272829123
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