Posts Tagged ‘Branding’

Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren

Introduction

In one of my previous articles where we investigated some of the new and awesome delegate controls in SharePoint 2013. It walks you through some of the interesting DelegateControl additions that I was playing around with. On top of that I got a comment about how you could extend it further by adding the current site title in the Suite bar:

image

Sure enough, I took a dive into the Seattle.master to take a look at how the title is rendered and found the control called SPTitleBreadcrumb. This is the control that is responsible for rendering the default out of the box title in a normal SharePoint team site like this:

image

So to follow the question through and provide an answer to get you started, we’ll take a quick look on how we can build further on our old sample from the previous blog post and add the site title (including or excluding breadcrumb-functionality) to the Suite bar.

Investigating the out of the box Seattle.master

In the OOTB Seattle.master, the title is rendered using the following code snippet:

<h1 id="pageTitle" class="ms-core-pageTitle">
  <SharePoint:AjaxDelta id="DeltaPlaceHolderPageTitleInTitleArea" runat="server">
    <asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server">
      <SharePoint:SPTitleBreadcrumb
              runat="server"
              RenderCurrentNodeAsLink="true"
                  SiteMapProvider="SPContentMapProvider"
              CentralAdminSiteMapProvider="SPXmlAdminContentMapProvider">
        <PATHSEPARATORTEMPLATE>
          <SharePoint:ClusteredDirectionalSeparatorArrow runat="server" />
        </PATHSEPARATORTEMPLATE>
      </SharePoint:SPTitleBreadcrumb>
    </asp:ContentPlaceHolder>
  </SharePoint:AjaxDelta>
  <SharePoint:AjaxDelta BlockElement="true" id="DeltaPlaceHolderPageDescription" CssClass="ms-displayInlineBlock ms-normalWrap" runat="server">
    <a href="javascript:;" id="ms-pageDescriptionDiv" style="display:none;">
      <span id="ms-pageDescriptionImage">&#160;</span>
    </a>
    <span class="ms-accessible" id="ms-pageDescription">
      <asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat="server" />
    </span>
    <SharePoint:ScriptBlock runat="server">
      _spBodyOnLoadFunctionNames.push("setupPageDescriptionCallout");
    </SharePoint:ScriptBlock>
  </SharePoint:AjaxDelta>
</h1>

What we can see in this file is that there’s a lot of action going on to simply render the title (or title + breadcrumb). You can play around with this in tons of ways, both server-side and client side. In this article we’ll take a look at how we can extend the Suite bar delegate control from my previous article in order to – using server side code – modify the title and breadcrumb and move it around a bit.

Should you want to get the title using jQuery or client side object models, that works fine too. But we can save that for another post.

Adding the Title Breadcrumb to the Suite bar

I’m going to make this short and easy. The very first thing you should do is head on over to my previous article “Some new DelegateControl additions to the SharePoint 2013 master pages” and take a look at the “SuiteBarBrandingDelegate Delegate Control” section and make sure you’ve got that covered.

Once you’ve setup like that, here’s some simple additional tweaks you can add to your Delegate Control in order for the breadcrumb to be displayed in the top row of SharePoint. Modify the content of the “SuiteBarBrandingDelegate.ascx.cx” (the file in my previous sample is named like that, in your case it may differ) to now look something like this:

protected void Page_Load(object sender, EventArgs e)
{
    // Register any custom CSS we may need to inject, unless we've added it previously through the masterpage or another delegate control...
    Controls.Add(new CssRegistration { Name = "/_layouts/15/Zimmergren.DelegateControls/Styles.css", ID = "CssReg_SuiteBarBrandingDelegate", After = "corev5.css" });

    BrandingTextControl.Controls.Add(new Literal
    {
        Text = string.Format("<a href='{0}'><img src='{1}' alt='{2}' /></a>",
            SPContext.Current.Site.Url,
            "/_layouts/15/images/Zimmergren.DelegateControls/tozit36light.png",
            SPContext.Current.Site.RootWeb.Title)
    });

    // Create a new Title Breadcrumb Control
    SPTitleBreadcrumb titleBc = new SPTitleBreadcrumb();
    titleBc.RenderCurrentNodeAsLink = true;
    titleBc.SiteMapProvider = "SPContentMapProvider";
    titleBc.CentralAdminSiteMapProvider = "SPXmlAdminContentMapProvider";
    titleBc.CssClass = "suitebar-titlebreadcrumb";
    titleBc.DefaultParentLevelsDisplayed = 5;

    // Add the Title Breadcrumb Control
    BrandingTextControl.Controls.Add(titleBc);
}

As an indication, the end-result might look something like this when you’re done. What we’ve done is simply copied the logic from the Seattle.master into the code behind file of our delegate control and set the “DefaultParentLevelsDisplayed” to a higher number than 0 so it’ll render the actual breadcrumb. By setting this value to 0, only the title will be displayed.

image

Then if you want to hide the default title, you can do that by using this small CSS snippet:

#pageTitle 
{
    display: none;
}

And it’s gone:

image

From there you should be able to take it onwards and upwards in term of the styling. I haven’t really put any effort into making it pretty here :-)

Summary

With these small additions and changes to my original code samples you can make the title bar, including or excluding the breadcrumb, appear in the top bar instead of in the default title-area.

Additional important comments:

You may need to consider ensuring that the Site Map datasource is available on every page, including system pages for example. If it isn’t or you land on a page that don’t want to render your breadcrumb/title, it may not be able to properly render your navigation as you would expect it to. However that’s something to look into further from that point.

For example, by default the “Site Content” link will not render the full breadcrumb properly, but rather just say “Home”. In order to fix smaller issues like that, we can further extend the code logic a few lines and take care of those bits.

My recommendation:

Always make sure you consider the approach you take for any type of customization and development. For this specific case, we’ve already used some code-behind to display our logo in the top left corner, so we’ve just built some additional sample code on top of that to render the breadcrumbs. However should we only want to do that and not move further onwards with the logic from here – I would most likely suggest you do this using jQuery/CSOM instead to be “Office 365 compliant” and keeping your customizations to a minimum.

Hope you enjoyed this small tweak. And keep in mind: Recommendations going forward (however hard it’ll be to conform to them) are to keep customizations to a minimum!

Cheers, Tob.

Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren

Introduction

In my previous post (http://zimmergren.net/technical/sp-2013-some-new-delegatecontrol-additions-to-the-sharepoint-2013-master-pages) I talked about how you could use the new delegate controls in the master page (seattle.master) to modify a few things in the SharePoint UI, including the text in the top left corner saying "SharePoint". If your goal is simply to change the text, or hardcode a link without the need for any code behind, you could do it even easier with PowerShell.

Changing the SharePoint text to something else using PowerShell

Before:

image

After:

image

PowerShell Snippet

$webApp = Get-SPWebApplication http://tozit-sp:2015
$webApp.SuiteBarBrandingElementHtml = "Awesome Text Goes Here"
$webApp.Update()

 

Enjoy.

Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren

Introduction

In this post we’ll take a quick look at some of the new DelegateControls I’ve discovered for SharePoint 2013 and how you can replace or add information to your new master pages using these new controls, without modifying the master pages. This is done exactly the same way as you would do it back in the 2010 projects (and 2007), the only addition in this case are a few new controls that we’ll investigate.

New DelegateControls

Searching through the main master page, Seattle.master, I’ve found these three new DelegateControls:

  • PromotedActions
  • SuiteBarBrandingDelegate
  • SuiteLinksDelegate

So let’s take a look at where these controls are placed on the Master page and how we can replace them.

PromotedActions Delegate Control

The PromotedActions delegate control allows you to add your own content to the following area on a SharePoint site in the top-right section of the page:

image

An example of adding an additional link may look like this:

image

So what does the files look like for these parts of the project?

Elements.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    
  <!-- DelegateControl reference to the PromotedActions Delegate Control -->
  <Control ControlSrc="/_controltemplates/15/Zimmergren.DelegateControls/PromotedAction.ascx"
           Id="PromotedActions"
           Sequence="1" />
  
</Elements>

PromotedActions.aspx (User Control)

<!-- Note: I've removed the actual Facebook-logic from this snippet for easier overview of the structure. -->
<a title="Share on Facebook" class="ms-promotedActionButton" style="display: inline-block;" href="#">
    <span class="s4-clust ms-promotedActionButton-icon" style="width: 16px; height: 16px; overflow: hidden; display: inline-block; position: relative;">
        <img style="top: 0px; position: absolute;" alt="Share" src="/_layouts/15/images/Zimmergren.DelegateControls/facebookshare.png"/>
    </span>
    <span class="ms-promotedActionButton-text">Post on Facebook</span>
</a>

SuiteBarBrandingDelegate Delegate Control

This DelegateControl will allow you to override the content that is displayed in the top-left corner of every site. Normally, there’s a text reading "SharePoint" like this:

image

If we override this control we can easily replace the content here. For example, most people would probably like to add either a logo or at least make the link clickable so you can return to your Site Collection root web. Let’s take a look at what it can look like if we’ve customized it (this is also a clickable logo):

image

So what does the files look like for this project?

Elements.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    
  <!-- SuiteBarBrandingDelegate (the top-left "SharePoint" text on a page) -->
  <Control ControlSrc="/_controltemplates/15/Zimmergren.DelegateControls/SuiteBarBrandingDelegate.ascx"
           Id="SuiteBarBrandingDelegate"
           Sequence="1" />
  
</Elements>

SuiteBarBrandingDelegate.ascx (User Control)

This is the only content in my User Control markup:

<div class="ms-core-brandingText" id="BrandingTextControl" runat="server" />

SuiteBarBrandingDelegate.ascx.cx (User Control Code Behind)

protected void Page_Load(object sender, EventArgs e)
{
    BrandingTextControl.Controls.Add(new Literal
    {
        Text = string.Format("<a href='{0}'><img src='{1}' alt='{2}' /></a>", 
        SPContext.Current.Site.Url,
        "/_layouts/15/images/Zimmergren.DelegateControls/tozit36light.png",
        SPContext.Current.Site.RootWeb.Title)
    });
}

SuiteLinksDelegate Delegate Control

The SuiteLinksDelegate control will allow us to modify the default links, and to add our own links, in the "suit links" section:

image

By adding a custom link to the collection of controls, it can perhaps look like this:

image

What does the project files look like for modifying the SuiteLinksDelegate? Well, here’s an example:

Elements.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  
  <!-- DelegateControl reference to the SuiteLinksDelegate Delegate Control -->
  <Control ControlSrc="/_controltemplates/15/Zimmergren.DelegateControls/SuiteLinksDelegate.ascx"
           Id="SuiteLinksDelegate"
           Sequence="1" />
  
</Elements>

 

SuiteLinksDelegate.aspx.cs (User Control Code Behind)

public partial class SuiteLinksDelegate : MySuiteLinksUserControl
{
    protected override void Render(HtmlTextWriter writer)
    {
        writer.RenderBeginTag(HtmlTextWriterTag.Style);
        writer.Write(".ms-core-suiteLinkList {display: inline-block;}");
        writer.RenderEndTag();
        writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-core-suiteLinkList");
        writer.RenderBeginTag(HtmlTextWriterTag.Ul);
            
        // The true/false parameter means if it should be the active link or not - since I'm shooting off this to an external URL, it will never be active..
        RenderSuiteLink(writer, "http://timelog.tozit.com", "Time Report", "ReportYourTimeAwesomeness", false);

        writer.RenderEndTag();
        base.Render(writer);
    }
}

Solution overview

For reference: I’ve structured the project in a way where I’ve put all the changes into one single Elements.xml file and they’re activated through a Site Scoped feature called DelegateControls. The solution is a Farm solution and all artifacts required are deployed through this package.

image

Summary

In this post we’ve looked at how we can customize some of the areas in a SharePoint site without using master page customizations. We’ve used the good-old approach of hooking up a few Delegate Control overrides to our site collection. Given the approach of Delegate Controls, we can easily just de-activate the feature and all our changes are gone. Simple as that.

In SharePoint 2013 we can still do Delegate Control overrides just like we did back in 2007 and 2010 projects, and it’s still pretty slick. I haven’t investigated any other master pages other than the Seattle.master right now – perhaps there’s more new delegate controls somewhere else. Let’s find out..

Enjoy.

SP 2010: Developing for performance Part 6 – CSS Sprites

April 8th, 2011 by Tobias Zimmergren

Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren

Introduction

SharePoint 2010 developing for performance article series:
In this series of articles I will briefly introduce you to some key concepts when it comes to developing for performance in our SharePoint 2010 applications.

Related articles in this article series

Part 1 – SP 2010: Developing for performance Part 1 – Developer Dashboard
Part 2 – SP 2010: Developing for performance Part 2 – SPMonitoredScope
Part 3 – SP 2010: Developing for performance Part 3 – Caching in SharePoint 2010
Part 4 – SP 2010: Developing for performance Part 4 – Logging
Part 5 – SP 2010: Developing for performance Part 5 – Disposal patterns and tools
Part 6 – SP 2010: Developing for performance Part 6 – CSS Sprites
Part 7 – SP 2010: Developing for performance Part 7 – Crunching those scripts
Part 8 – SP 2010: Developing for performance Part 8 – Control that ViewState

Part 6 (this article):
In web development today its very important to keep performance in mind – this is especially important in any site that is published externally or for whatever reason will have heavy traffic. In this article I will briefly cover the area of CSS Sprites, how they are implemented in SharePoint 2010 and of course how you can create them yourself.

Introduction to CSS Sprites

What are CSS sprites anyway?

CSS sprites is a technique used to reduce the number of requests for images on a site when visiting it. Normally when you see a web site today there’s plenty of files being requested and loaded upon the request made. With the use of CSS sprites we can reduce the amount of files that we need to request from the server by consolidating many image files into one file and use CSS to display the correct part of that consolidated image when it needs to depict your specific image.

Short in short: Take a bunch of separate images and smack them together to one single file. Voila, you’ll only need to request one file from the server.

SharePoint 2010 and CSS Sprites

So why are we talking about CSS sprites here anyway, isn’t this supposed to be all about SharePoint and awesomeness? But of course, and that’s exactly why we’re talking about it – CSS sprites are a natural part of a normal SharePoint 2010 installation. By default, there’s CSS sprite techniques used to render and display images in (for example) the Ribbon menu.

These are some samples of images used with CSS sprites in SharePoint 2010:

FGIMG.PNG jsgridcluster.png
FGIMG jsgridcluster

As you can see in any of the two images above the many small images/icons have been smashed together into one single image file and then there’s some CSS magic to position it. This is basically what it’s all about.

Why should I bother learning to use CSS sprites?

This would be like asking yourself the question "Why would I develop something that is of great performance" or "Why would I do something awesome". No more rhetorical questions please ;-)

Of course the reasoning behind creating CSS sprites are that you can develop web applications that can reduce the page load and enhance the performance of your sites and make them load quicker and be more responsive.

Creating CSS sprites for my applications? How?

There’s a few ways to create CSS sprites for you own applications.

  • Do it manually.
    • This approach requires a lot from you (the designer) in order to hack it up properly and make sure it’s pixel-correct.
  • Do it using a tool
    • This approach is what I normally use.
    • With any of the tools on the market to create CSS sprites you’re better off than doing it manually – all you have to do is dump you images into an application and it’ll output one single image along with the CSS markup for that. Awesome.

For obvious reasons mentioned above I will not be demonstrating how to do this manually but will rather be using any of the hundreds of tools out there to create the sprites.

In this example I’m going to use my main man Waldek’s tool called SpriteGenerator.

There’s a bunch of other tools available to create and generate these sprites as well of course, bing.com is thy friend.

How to: Generate CSS sprites using a tool

In this section I’ll talk you through our current application and what it looks like, what we want to achieve and finally how to achieve it.

Our current application, a visual sample

This is my current sample application before we start using sprites.

Control Panel Web Part (dummy):
image

This is the Visual Studio project, containing all the images and resources:
image

As you can see there’s quite some images being loaded. The images used in the application (my Web Part) will be fetched using a normal HTTP-request and that’s when one could realize how quickly those small requests can add up to impact performance.

This application uses some generic HTML markup like this:

         <div  class="width300p"> 
             <div  class="leftalign floatleft width30"> 
                 <div  class="height70p"><asp:Image  ID="Image2"  runat="server"  ImageUrl="/_layouts/images/TOZIT.CSSSprites/mail.png"  /></div> 
                 <div  class="height70p"><asp:Image  ID="Image3"  runat="server"  ImageUrl="/_layouts/images/TOZIT.CSSSprites/message.png"  /></div> 
                 <div  class="height70p"><asp:Image  ID="Image4"  runat="server"  ImageUrl="/_layouts/images/TOZIT.CSSSprites/more.png"  /></div> 
             </div> 
             <div  class="centeralign floatleft width30"> 
                 <div  class="height70p"><asp:Image  ID="Image5"  runat="server"  ImageUrl="/_layouts/images/TOZIT.CSSSprites/notebook.png"  /></div> 
                 <div  class="height70p"><asp:Image  ID="Image9"  runat="server"  ImageUrl="/_layouts/images/TOZIT.CSSSprites/search.png"  /></div> 
                 <div  class="height70p"><asp:Image  ID="Image13"  runat="server"  ImageUrl="/_layouts/images/TOZIT.CSSSprites/favorites.png"  /></div> 
             </div> 
             <div  class="width30 floatright"> 
                 <div  class="height70p"><asp:Image  ID="Image6"  runat="server"  ImageUrl="/_layouts/images/TOZIT.CSSSprites/info.png"  /></div> 
                 <div  class="height70p"><asp:Image  ID="Image7"  runat="server"  ImageUrl="/_layouts/images/TOZIT.CSSSprites/logoff.png"  /></div> 
                 <div  class="height70p"><asp:Image  ID="Image8"  runat="server"  ImageUrl="/_layouts/images/TOZIT.CSSSprites/question.png"  /></div> 
             </div> 
         </div>

Now, in order for us to utilize the CSS sprites instead, and not have to make a request for each of the images separately – we’ll use the SpriteGenerator and create us some nice CSS sprite magic.

Using the Sprite Generator to make some magic

Like I said before, we’ll be using Waldek’s SpriteGenerator for this sample.

Just open it, put in the images you’d like for it to make some magic with and then simply hit the magic button.

Tip: Check out how to use the SpriteGenerator here

The result of using the SpriteGenerator can look something like this:
image

This is one consolidated image containing all the graphic from my application. But instead of having about 30 different icons in my project, I now have only one.

The generator will create the CSS needed as well, and it can look something like this:

.sprite { background: url(‘/_layouts/images/TOZIT.CSSSprites/TOZIT_Sprite.png’) no-repeat top left; }
.pc { background-position: -0px 0; width: 47px; height: 64px; }
.question { background-position: -47px 0; width: 53px; height: 64px; }
.info { background-position: -100px 0; width: 54px; height: 64px; }
.mail { background-position: -154px 0; width: 54px; height: 64px; }
.more { background-position: -208px 0; width: 54px; height: 64px; }
.user { background-position: -262px 0; width: 55px; height: 64px; }
.world { background-position: -317px 0; width: 55px; height: 64px;  }
.video { background-position: -372px 0; width: 56px; height: 64px; }
.favorites { background-position: -428px 0; width: 57px; height: 64px; }
.edit { background-position: -485px 0; width: 60px; height: 64px; }
.date { background-position: -545px 0; width: 64px; height: 57px; }
.file { background-position: -609px 0; width: 64px; height: 64px; }
.group { background-position: -673px 0; width: 64px; height: 58px; }
.home { background-position: -737px 0; width: 64px; height: 62px; }
.left_arrow { background-position: -801px 0; width: 64px; height: 59px; }
.logoff { background-position: -865px 0; width: 64px; height: 78px; }
.notebook { background-position: -929px 0; width: 64px; height: 51px; }
.rigth_arrow { background-position: -993px 0; width: 64px; height: 57px; }
.search { background-position: -1057px 0; width: 64px; height: 61px; }
.sound { background-position: -1121px 0; width: 64px; height: 58px; }
.stop { background-position: -1185px 0; width: 64px; height: 59px; }
.vault { background-position: -1249px 0; width: 64px; height: 53px; }
.message { background-position: -1313px 0; width: 66px; height: 64px; }
.image { background-position: -1379px 0; width: 84px; height: 84px; }
.tozitlogo { background-position: -1463px 0; width: 250px; height: 101px; }

Now, what this really means is that you now have the ability to actually use only one single image to portray several.

New Visual Studio structure

Obviously, with the new update and only using one single image – the Visual Studio project might look something like this:

image

New HTML markup

And finally, there needs to be some changes in the HTML markup to reflect the changes with the images. The markup could look something like this:

         <div  class="leftalign floatleft width30"> 
             <div  class="height70p sprite mail">&nbsp;</div> 
             <div  class="height70p sprite message"  >&nbsp;</div> 
             <div  class="height70p sprite more"  >&nbsp;</div> 
         </div>

How does using CSS Sprites affect requests, hence performance?

Dealing with sprites isn’t very hard to get started with as you saw in the previous short samples. But what’s more interesting from a performance perspective is of course how it can affect the performance of the requests being made towards the server.

Let’s do some generic Fiddler-magic to see what the requests look like without using sprites and then what the requests look like with the use of sprites.

Fiddler test 1: NOT using CSS sprites

image

Request Count 17 total requests made to the server!
Bytes Sent 8 137 bytes
Bytes Received 76 164 bytes

Fiddler test 2: Using CSS sprites

image

Request Count 3 total requests made to the server!
Bytes Sent 1 722 bytes
Bytes Received 139 369 bytes

What you can easily conclude from the initial tests is that there’s more requests without the CSS sprites, while the size can be slightly larger for a consolidated image when using the sprites.
It’ll load and render quicker by downloading only the 3 files instead of the 17 files due to the aggregation time it takes to render the content.

Visualize the results, please!

Using CSS sprites
(Time in seconds to load the data)
NOT using CSS sprites
(Time in seconds to load the data)
image image

RESPONSE BYTES
image/png:    120 250
text/html:    16 593
~headers~:    1 748
text/css:    778

RESPONSE BYTES
image/png:    52 417
text/html:    16 709
~headers~:    6 260
text/css:    778

ACTUAL PERFORMANCE
Aggregate Session time:   
00:00:00.531 (0.5 seconds)
Sequence (clock) time:
00:00:00.4281250 (0.4 seconds)

ACTUAL PERFORMANCE
Aggregate Session time:
00:00:01.390 (1.3 seconds)
Sequence (clock) time:
00:00:00.5625000 (0.5 seconds)

I did some tests with two machines, two different projects and a couple of clients to request the pages and the results (on average) was something like this in rendering time. The chart below is a relative visualization of the results per average.

Chart

Summary

The impact of a system with a lot more requests for data than these samples, more users and in generally more traffic would differ a bit more than the charts here. Using sprites in combination with caching the data is a good practice to keep the amount of requests to the server to a minimum.

Even if this minor change don’t have any critical impact on improving the performance it’s important to consider. "All improvements are good improvements".

Ten (10) Free SharePoint Themes – Visual Overview

March 23rd, 2009 by Tobias Zimmergren

As many of you already have seen, there’s a set of free themes out there for use with your SharePoint sites. They can be downloaded here:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=0a87658f-20b8-4dcc-ad7a-09ad22641f3a

These themes are to be used with the Visual Studio 2008 Extensions for SharePoint (VSeWSS)

Article Overview

I got myself together and summarized all the themes below, where you will find a screenshot of each of the ten themes in action and you can decide for yourself if this is something you’re interested in exploring further.

My tip is: Check them out!

Preview: Corporate Site Theme

image

Preview: Team Site Theme

image

Preview: Publishing Site Theme

image 

Preview: Sports Site Theme

image

Preview: Construction Site Theme

image 

Preview: Contoso Site Theme

image 

Preview: Events Site Theme

image

Preview: Owner Approver Reviewer Participant Site Theme

image

Preview: Procurement Site Theme

image

Preview: Startup Site Theme

image 

Summary

Alright, that was the 10 new SharePoint themes available for free here

[Tiny post]

As many of you might have experienced when you create your own custom list definition, you can also create your custom forms (DispForm.aspx for example).

In my case, I want the DispForm.aspx to use another master page than it originally does, and so I thought I’d just change the following line of my DispForm.aspx:

From:

<%@ Page language="C#" MasterPageFile="~masterurl/default.master" …%>

To:

<%@ Page language="C#" MasterPageFile="~/_layouts/zTest/test.master" …%>

Problem

Doing this will most likely cause you to receive the following known error message:

An error occurred during the processing of . The referenced file ‘/_layouts/zTest/test.master’ is not allowed on this page.

Solution/Workaround

Instead of changing the MasterPageFile attribute of the Page directive, inject some server-side script in the DispForm.aspx in order to change the MasterPageFile property though code.

In your DispForm.aspx, do the following:

  • Keep the MasterPageFile=”~masterurl/default.master” attribute
  • Insert the following server-side script directly undet the <%@ Page … %> directive:

<script runat="server">
    protected void Page_PreInit(object sender, EventArgs e)
    {
        this.MasterPageFile = "~/_layouts/zTest/test.master";
    }
</script>

  • Watch your DispForm.aspx use a new Master Page without getting the error message.

Thanks to

I’d like to shout out to MVP Eric Schupps for giving me this smart tip.
I just might buy you a beer, Eric.