Hello,
I have a Windows Forms application that adds a new property in the property bag of the site collection, using the Client Object Model.
When I start the application the property is added, I can get or set its value, everything works fine.
The problem is that if I close the application and then start it again, the property added is no longer part of the spWeb.AllProperties property bag.
Am I doing something wrong? If so, which is the correct way of adding a new property in the property bag?
Here is my code:
Site spSite = clientContext.Site;
clientContext.Load(spSite);
clientContext.ExecuteQuery();
Web spWeb = spSite.RootWeb;
clientContext.Load(spWeb);
clientContext.ExecuteQuery();
if (spWeb.AllProperties.FieldValues.ContainsKey("MB_Sol")
spWeb.AllProperties.FieldValues["MB_Sol"] = "Licensed";
else
spWeb.AllProperties.FieldValues.Add("MB_Sol", "Licensed");
spWeb.Update();
clientContext.Load(spWeb);
clientContext.Load(spWeb.AllProperties);
clientContext.ExecuteQuery();
I also tried doing it like this:
spWeb.AllProperties["MB_Sol"]="Licensed";
but it's still not persisted.
Normally, in the Server Object Model I used spWeb.SetProperty, but this is not available in the client object model.
Answer needed asap!
Thank you,
Alice
I have a Windows Forms application that adds a new property in the property bag of the site collection, using the Client Object Model.
When I start the application the property is added, I can get or set its value, everything works fine.
The problem is that if I close the application and then start it again, the property added is no longer part of the spWeb.AllProperties property bag.
Am I doing something wrong? If so, which is the correct way of adding a new property in the property bag?
Here is my code:
Site spSite = clientContext.Site;
clientContext.Load(spSite);
clientContext.ExecuteQuery();
Web spWeb = spSite.RootWeb;
clientContext.Load(spWeb);
clientContext.ExecuteQuery();
if (spWeb.AllProperties.FieldValues.ContainsKey("MB_Sol")
spWeb.AllProperties.FieldValues["MB_Sol"] = "Licensed";
else
spWeb.AllProperties.FieldValues.Add("MB_Sol", "Licensed");
spWeb.Update();
clientContext.Load(spWeb);
clientContext.Load(spWeb.AllProperties);
clientContext.ExecuteQuery();
I also tried doing it like this:
spWeb.AllProperties["MB_Sol"]="Licensed";
but it's still not persisted.
Normally, in the Server Object Model I used spWeb.SetProperty, but this is not available in the client object model.
Answer needed asap!
Thank you,
Alice