Masterpage Code Behind and Class Libraries

Aug 21, 2008 at 10:23 AM
Edited Aug 22, 2008 at 1:27 PM
Well are enough links about creating Custom Site Templates but I always miss the option of supporting code behind. Yours does, thank you!

Because I also needed a code behind for my custom master page I trialed around and this works now too. Steps involved:

1. Create a new class  '_master' which derives from class 'MasterPage'
2. Add to the master aspx page the following: Inherits="[YourNameSpace]._master"

I also needed support for custom class libraries. It first did not work but later I noticed I had to set output build path point to the 'Assemblies' folder of de deployment solution. I don't know if this is the right solution but it works. And of course I had to add these assemblies to the 'ManifestTemplate.xml'

I also like to add to this posting the following problems with their solution when trying to build/run it for the very first time:

~ Problem
Upon running 'deploy.cmd' the script shows errors like 'The timer job for this operation has been created, but it will fail ...'
Goto the Administrative Tools and open Services. Probably Service 'Windows SharePoint Services Administration' isn't running. Start it and you are advised to set property 'Startup Type' to 'Automatic'.
~ Problem
The SharePoint Worker Process Group ... job failed with the following error.  This job will be skipped. Failed to connect
 to an IPC Port: Access is denied.
When you start the 'Windows SharePoint Services Administration' service for the very first time you probably have forgotten to restart your SharePoint machine.
~ Problem
Errors during creation of a new site in SharePoint based on your freshly made Custom Site Template (for example the Masterpage cannot be found).
I noticed sometimes deployment problems occur when having a WSP Project Template based Solution open and running repeatedly the deployment scripts (like 'deploy.cmd'). Close everything and rerun deployment scripts.

Yours sincerely,

Evert Wiesenekker