Conversations On tech, literature, art and business

9Feb/120

A Rose By Any Other Name, May Not Compile

Short, informational post here.

Custom properties for Sharepoint 2010 webparts. I created several this past week using the following syntax:

[Category("Advanced Settings"),
Personalizable(PersonalizationScope.Shared),
WebBrowsable(true), WebDisplayName("Items to show"),
WebDescription("The number of RSS feed items to show")]
public uint ItemCount
{
get;
set;
}

No issues, compile and deploy as per normal. But when I go to set said properties from the UI they are nowhere to be found...

Slightly frustrated, I do some deeper research. 99% of the online examples I find agree with my method. But, deep in the bowels of MSDN I find an alternative:

[SPWebCategoryName("Advanced Settings"),
Personalizable(PersonalizationScope.Shared),
WebBrowsable(true), WebDisplayName("Items to show"),
WebDescription("The number of RSS feed items to show")]
public uint ItemCount
{
get;
set;
}

Yes Virginia, another category designator makes all the difference.

I hope this helps others with the same issue. To help you find this post I'll spell it out:

Sharepoint 2010 webpart property not showing in UI edit mode.

I wonder how many folks will find their way here based on the Google search above.

Happy coding.

p.s. the first example requires using System.ComponentModel; while the second needs using Microsoft.SharePoint.WebPartPages;

As it turns out I had another issue that was causing the properties to not render :/ That being said, the WebPartPages library is the preferred one to use.

I would love to hear opinions on this from all you sharp devs out there. I'm happy to hear alternative views.

Filed under: Uncategorized No Comments