How to add your own WebPart properties

If you are creating your own part you might want to add a property for the users to set when editing the webpart.

At the top of your web part class add the following code (before any methods).

[FriendlyName("Project Site Template")]
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
public string ProjectsiteTemplateName { get; set; }

This will add a property (in my case called Project Site Template) for the users to set when editing the web part.

This allows the user configure the web part for what you need (instead of hard coding some things).

[tweetmeme only_single=”false”]
Advertisements

Got something to add?

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