Reza on blogging [MVP]

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

Subscriptions

<January 2009>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

News



toronto.sharepoint.camp


Navigation

Post Categories

Other Bloggers

Personal Links

Wednesday, July 25, 2007 - Posts

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 Wednesday, July 25, 2007 4:15 PM by rezaa with 0 Comments

Powered by Community Server, by Telligent Systems