3

With this attributes decorating the Properties of a Web Part...

[WebBrowsable(true)]
[Category("Common Settings")]
[WebDisplayName("Show tab header")]
[WebDescription("Show tab header for the News Feed webpart")]
[Personalizable(PersonalizationScope.Shared)]

... is the [WebPartStorage(Storage.Shared)] implied when using the above attributes (PersonalizationScope.Shared), or are the value stored for each user if Storage.Shared is not explicitly set.

1 Answer 1

5

PersonalizationScope.Shared indicates that the property is not personalizable. PersonalizationScope.User indicates that the property is personalizable.

Also, from the documentation for WebPartStorage: If you are developing SharePoint 2003 Web parts, you can apply both the PersonalizableAttribute attribute and the WebPartStorageAttribute attribute to change the serialization method. However, for later versions of SharePoint, the PersonalizableAttribute attribute is the default option used to deserialize the web part before using the WebPartStorageAttribute attribute.

3
  • To clarify: In Sharepoint 2010. Do we need to add [WebPartStorage(Storage.Shared)] to store the value only once? If we skip it will the value be stored seperatly for each user? May 10, 2011 at 12:15
  • +1, and I'd like to add: actually, webparts were born in SharePoint 2003, and in 2005 they were moved into ASP.Net framework 2.0. From that time, System.Web.UI.WebControls.WebParts is more preferrable to use, and Microsoft.SharePoint.WebPartPages is usually not recommended (for example, see remarks section of this MSDN article: msdn.microsoft.com/en-us/library/… article) May 10, 2011 at 12:23
  • 1
    In SharePoint 2010 you do not need to use the WebPartStorage attribute. SharePoint can get all the information it needs from the Personalizable attribute. When using the Personalizable attribute, you should pass PersonalizationScope.Shared to the constructor to prevent personalization (i.e. values being stored for each user). May 10, 2011 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.