Saving hidden WebPart properties

I quite often use hidden web part properties for sensitive information and properties that I just don't want the user to update.  With WSS 2.0 and the Microsoft.SharePoint.WebPartPages.WebPart namespace, this was easily achieved by setting:

this.SaveProperties = true;

On moving to MOSS and WSS 3.0 I decided to use the System.Web.UI.WebControls.WebParts.WebPart namespace (as recommended) and of course the SaveProperties property does not exist.  I could of course continue using the original namespace, but that would mean that the web part could only be hosted on a SharePoint site, and it was my intention to broaden the scope a little.

After a fair amount of Google searching I stumbled across the solution.  The method I was looking for was:

this.SetPersonalisationDirty();

So problem solved!

Leave a Reply