Skip to content

Using custom web part properties with WPSC

July 27, 2006

The following was reposted from:

Web Part Page Services Component (WPSC) is a feature of SharePoint that lets you interact with your web parts through client-side script.

While working on a recent web part, I wanted to access the a custom property using WPSC but was getting errors when trying to save it. It turned out that the problem was that my custom properties weren’t being serialized to Xml because it was the holding the default value after being initialized.

From the 2003 SDK:

[…] do not use the DefaultValue attribute if you want properties to be accessible through the Web Part Page Services Component (WPSC). If it exists and a property is set to the default, the property won’t appear in the WPSC Properties collection. In this case, provide a ShouldSerializeXXX method for your property.

If you have both DefaultValue attribute and define a ShouldSerializeXXX method, the DefaultValue attribute’s effect overrides the ShouldSerialeXXX method.

There are a lot of interesting things you can do if you can access your web part through client-side script. And SharePoint provides an infrastructure for this but I haven’t seen many web parts that take advantage of it. Think AJAX.


From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: