Monday, November 22, 2010

SharePoint 2010: Web Part Properties

Even though I've made SP2010 web parts before for some reason I couldn't find any good articles on how to add Custom Properties to a web part.

So here is my take on a Custom SharePoint 2010 Web Part Property:
private string _targetSite = "SomeSite";
[Personalizable(PersonalizationScope.Shared),
WebBrowsable(true),
WebDisplayName("Target Site"),
WebDescription("Specify a site."),
Category("Configuration")]
public string TargetSite
{
get { return _targetSite; }
set { _targetSite = value; }
}

Oh and make sure you have the permissions to change settings.

No comments:

Post a Comment