SharePoint 2010 Branding: Responsive HTML5 masterpage for SharePoint 2010

Kyle Schaeffer created a great looking HTML5 enabled masterpage for Sharepoint 2010. I was testing it around and since the deployment instructions where all manual uploads to SharePoint lists and whatnot I decided to automate this process. I created a Visual Studio solution with all the files and a feature that will activate the whole thing.

So the solution includes all the unaltered files provided by Kyle Schaeffer, under the Creative Commons Attribution license 3.0. The only thing i did was create the solution and the code to activate the master page in the feature event receiver.

Be sure to read the whole article HTML5 enabled masterpage for Sharepoint 2010. There are important limitations to this solution.

This is how the solution looks like:

The most important method in the event receiver, to change the active site and system master page.

private void UpdateMasterPage(SPWeb web, String newMasterFileName) {
    try {                
        bool webAllowUnsafeUpdates = web.AllowUnsafeUpdates;

        web.AllowUnsafeUpdates = true;

        web.CustomMasterUrl = web.CustomMasterUrl.Replace(Path.GetFileName(web.CustomMasterUrl), newMasterFileName); // Site Masterpage
        web.MasterUrl = web.MasterUrl.Replace(Path.GetFileName(web.MasterUrl), newMasterFileName); // System Masterpage

        web.AllowUnsafeUpdates = webAllowUnsafeUpdates;               
    catch (Exception e) {

The feature is activated at site collection level.

You can download the wsp file and the Visual Studio solution I've created under the same license (Creative Commons Attribution license 3.0) as the original files. See this article's attachments at the end.


Related articles