After SharePoint Saturday in Copenhagen a while back I promised to upload my code-samples from my demos. Being a bit busy the last few days, it’s been taking a bit longer than expected.
I’ve been looking through the evaluation forms from the event, and wow – thank you for the support everyone who attended my session. It couldn’t possibly be any better than this :-)
You made my day, and I hope I made your day as well!
Never fear, the code is here!
Example 1: Write to the ULS logs (12LOGS) folder
I showed a demo of how you can write to the logs in your 12-hive, using the examples on MSDN to start out from.
This project simply wraps the ULS-stuff into a class and lets you statically call the method to log stuff in the 12-hive.
Remember, you need to compile this code as unsafe. If that’s a problem for you, please consider using another approach.
Download code: ULSDemo.zip
Example 2: Clean up those .wepbart files when you don’t need them anymore
In this example I showed you how you can easily clean up the .webpart files after you when you deactivate your WebPart Feature.
If you deploy a web part using a feature, and then deactivate the feature and remove the solution – your .webpart file will remain in the Web Part gallery which could lead to some confusion as you still can try to add it to a page, only to result in an error.
To prevent that, I’ve got a small snippet that cleans those files up when you deactivate your feature.
Note: If you’re playing a lot with Web Part properties and you re-deploy your solution and during that process will deactivate/activate the feature, the old .webpart files will be replaced by new copies – this means that your web par properties also can be affected!
Download code: WebPartCleanupDemo.zip
Example 3: SPExLib – SharePoint Extensions Library (.net 3.5)
Using the SharePoint Extensions Library (www.codeplex.com/spexlib) you are provided with a great set of extra extensions to your normal SPobjects.
Please see my very simple example for an understanding of what I talked about and showed at SPSaturday Copenhagen.
Download code: SPExLibDemo.zip
There you go – some of the examples I created during SharePoint Saturday Copenhagen. Enjoy.
Please leave a comment if you’ve got any questions, comments or just feedback.