17.1.12

Web Part property attributes

Browsable
Set to false if you don't want to display the custom property in the property pane. Also, if you set the WebPartStorage attribute to Storage.None, your property won't display in the property pane.

Category
The title of the section of the property pane that you want created to display the custom property. If you don't specify the Category attribute or if you specify the Categoryattribute as "Default", your custom property is displayed in the Miscellaneous section of the property pane.

DefaultValue
The default value of the custom property. Specifying the default value minimizes the Web Part's storage requirements by storing the property's value only if it is different from the default.

Description
The contents of the tool tip that appears when you pause the mouse pointer over the custom property in the property pane.

FriendlyNameAttribute
The caption displayed for the custom property in the property pane. If you don't specify this attribute, the actual property name will be displayed in the property pane.

HtmlDesignerAttribute
Used to associate a property builder with the property.

ReadOnly
Set to true if you want the custom property to be read-only in the property pane.

ResourcesAttribute
Used to provide localized names for FriendlyName, Category, and Description in the tool pane for the custom property.

WebPartStorage
Set to Storage.Shared to display the custom property in the property pane when the user is in shared view of the page. Set to Storage.Personal to display the custom property in the property pane when the user is in Shared or Personal view of the page. Set to Storage.None if you don't want the setting to persist for the custom property. The custom property won't be displayed in the property pane.

 

[Category("Custom Properties")]
[DefaultValue(c_MyBoolDefault)]
[WebPartStorage(Storage.Personal)]
[FriendlyNameAttribute("Custom Boolean")]
[Description("Select to set value to True.")]
[Browsable(true)]
[XmlElement(ElementName="MyBoolean")]
// The accessor for this property.
public bool MyBool
{
get
{
return _myBool;
}
set
{
_myBool = value;
}
}

No comments:

Post a Comment