Clearing or removing a key&value from SPWeb.Properties (Tips&Tricks)


this quick trick can be use for removing a property correctly form SPWeb object.

string key="Identifier";
if (!web.Properties.ContainsKey(key))
{
return; //make a check is already exists.
}
web.AllProperties.Remove(key); //first clear from AllProperties.
web.Properties[key] = null; // remove property value
web.Update(); //update web object.
web.Properties.Update(); // update properties object.

See you in next tips…

Advertisements

About bpostaci
Escalation Engineer in Microsoft.

One Response to Clearing or removing a key&value from SPWeb.Properties (Tips&Tricks)

  1. Angel says:

    Well done! Finally an entry in internet about removing properties from SPWeb that works. Thanks a lot!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: