Using custom web part properties with WPSC
The following was reposted from: http://vspug.com/kwanl/2006/07/27/using-custom-web-part-properties-with-wpsc/
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.