9

What is the difference between the attributes WebBrowsable and Personalizable in a Sharepoint 2010 web part?

e.g.

[Personalizable(), WebBrowsable]
public string IconURL { get; set; }

vs

[WebBrowsable]
public string IconURL { get; set; }

MSDN gives the impression that personalizable is per user, whereas webbrowseable is for all users - however it doesn't explicitly mention this and I would like to get this sorted in my head.

E.g. can I set a user specific property on personalizable and web-part wide on webbrowsable?

Darbio
  • 11,286
  • 12
  • 60
  • 100

3 Answers3

15

The WebBrowseable attribute specifies that the decorated property should appear in the editor component of the web part. It only allows the end user to modify the property and does nothing about persistence.

The Personalizable attribute specifies that the value of the decorated property must be persisted in the SharePoint backend, either in the user store (by default) or in the shared store (if the Shared scope is specified). It only cares about persistence and does nothing about the property presence in the editor component.

So, if you decorate a property with [WebBrowsable] and not [Personalizable], the end user will be able to modify it in the editor component but its new value won't be persisted.

Conversely, if you decorate a property with [Personalizable] and not [WebBrowsable], its value will be persisted but the end user won't be allowed to modify it.

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
  • So when you set the attribute to `WebPartStorage(Storage.Shared)` the settings should be persisted for all users, wheras `WebPartStorage(Storage.Personal),` is only for one user? – Darbio Dec 06 '10 at 23:36
  • @JD, yes. [[`WebPartStorage`](http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpartstorageattribute.aspx)] is the SharePoint Online equivalent to `[Personalizable]`. – Frédéric Hamidi Dec 07 '10 at 06:34
  • Important to note that even if WebBrowseable is set to true you can still edit the property through a custom EditorPart. – knight0323 Dec 09 '10 at 22:11
  • Can you please take a look at my question http://stackoverflow.com/questions/23486587/persisting-custom-asp-net-webpart-properties.I hope you ll understand my question... @FrédéricHamidi – Vignesh Kumar A May 06 '14 at 05:39
2

WebBrowsable will make the property appear in the ToolPane or EditorPart of the WebPart.

Personalizable will allow the property to be stored and persisted in the personalization store. There is an enum in which you can specify weather this property will store per user values or a single value for all users.

WebBrowsable is also property specific as Personalizable.

Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124
  • Can you please take a look at my question http://stackoverflow.com/questions/23486587/persisting-custom-asp-net-webpart-properties.I hope you ll understand my question... – Vignesh Kumar A May 06 '14 at 05:41
1

WebBrowsable [WebBrowsable(True)] "Indicates whether the designated property of a Web Parts control is displayed in a PropertyGridEditorPart object." (MSDN) http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webbrowsableattribute.aspx

Personalizable [Personalizable(true)] Allows users the ability to personalize settings for the WebPart. http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.personalizableattribute.aspx

Vivek Jagga
  • 502
  • 1
  • 5
  • 13