SharePoint Explored

Just another WordPress.com weblog

How to order Web Part properties

I was wondering if there is a way to order the web part properties with the web part has no custom ToolPart associated with it. There is a simple solution for this: just override the GetToolParts() method of the web part and add the tool parts in the desired order. There are some default ToolPart objects we have to add here.

  • WebPartToolPart is responsible for rendering the default properties in the categories, Appearance, Layout and Advanced
  • CustomPropertyToolPart is responsible for adding the browsable properties defined within the web part

Here is the code which does this:


public
override ToolPart[] GetToolParts()

{
ToolPart[] toolparts = new ToolPart[2];
WebPartToolPart defaultToolPart = new WebPartToolPart();
CustomPropertyToolPart browsableProperties = new CustomPropertyToolPart();

toolparts[0] = browsableProperties;
toolparts[1] = defaultToolPart;

return toolparts;
}

Advertisements

February 2, 2010 - Posted by | SharePoint Hack

No comments yet.

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: