in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

kwanl's blog

July 2006 - Posts

  • 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.

  • Don't trust SharePoint error messages

    Recently we've been trying to automate the provisioning of web part pages that require many customized web parts. Because of design issues we decided to do this from a ASPX page in the _layouts folder.

    Things we going smoothly until we started getting the dreaded "not registered as safe" errors when trying to add our web parts. That was not the case because the web parts were installed and running. Through some experimentation, we discovered that it worked if the web parts were in the GAC. Combining the confusing error message and this new information would lead you to believe that you're dealing with a security issue. That is not the case.

    The real problem was that the web part assemblies could not be located by the ASPX page in _layouts. So it was really an assembling binding error.

    Solution: Use a web service to add the web parts to the web part page.

    Daniel Larson ran into a similar problem:

    http://www.portalbuilder.org/sites/daniellarson/blog/Log/DisplayLog.aspx?ID=30


Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts