WebBrowsable vs Personalizable in Web Parts
Asked Answered
D

3

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?

Dimmer answered 6/12, 2010 at 0:28 Comment(0)
B
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.

Blasphemy answered 6/12, 2010 at 10:35 Comment(4)
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?Dimmer
@JD, yes. [WebPartStorage] is the SharePoint Online equivalent to [Personalizable].Paragraph
Important to note that even if WebBrowseable is set to true you can still edit the property through a custom EditorPart.Sherrer
Can you please take a look at my question #23487087 hope you ll understand my question... @FrédéricHamidiAmadeus
A
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.

Anthropocentric answered 6/12, 2010 at 10:32 Comment(1)
Can you please take a look at my question #23487087 hope you ll understand my question...Amadeus
K
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

Kriskrischer answered 6/12, 2010 at 10:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.