How to use Web Part Custom Properties in SharePoint 2007 and WSS 3.0

t’s so weird how so many people ask you the same thing around the same time sometimes, anyway I’ve had some request around on how to create custom properties for Web Parts in SharePoint, more to the point, on how to get them to categorise and appear in the “Modify Web Part” panel.

It’s quite simple actually, just declare the properties and decorate them with attributes like in the following example:

[WebBrowsable(true),

Personalizable(true),

Category(“RSS Aggregator Web Part”),

DisplayName(“URLs of the Feed”),

WebDisplayName(“URLs of the Feed”),

Description(“Please enter the URLs of the feed separated by ‘;’ character.”)]

public string FeedURL

{

get

{

return rssUrl;

}

set

{

rssUrl = value;

}

}

Please note that Category attribute will basically create section for all your properties that carry that attribute value and WebDisplayName will be the name of the property appearing on the panel.

Advertisements

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: