Changing WebPart properties

Some things are just not obvious, or maybe I am just getting spoiled. Well, I just spent a couple of hours trying to figure out why Sharepoint didn't bother to persist my changed WebPart Title property through postbacks. First I thought this was due to my UserControl approach, and was caused by the ASP.NET UserControl beeing routed around Sharepoints ISAPI stuff.

Then I noticed that the main property of my webpart, which is a WebPart Connection Consumer class btw, was reset on postback. My Cell Provider webpart calls the consumer correctly and the property CompanyID which is marked with the attribute WebPartStorage(Storage.Personal) is set in the CellReady eventhandler of the consumer. I naturally assumed that this would be stored in Storage.Personal because of the attribute marking.

Enter protected bool WebPart.SaveProperties. Nuff said...

 

1 Comment

  • I had a similar problem: spending hours trying to figure out why my properties wouldn't persist. Even with the SaveProperties set to true, I was geting exceptions. Turns out that you need to have permission to access the Sharepoint database for persistence to work (makes sense, I suppose). So, that means you need a web part that is signed, trusted by web.config, and resides in the GAC.



    I may be in error, but my understanding from reading is that the GAC gives an all-or-nothing approach to the machine.



    Anyone know of some good URLs which will explain how to only grant permissions to do the task at hand and not total access to the machine?

Comments have been disabled for this content.