8

I have the following code line that adds the default.master to a custom aspx page;

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ConvertStatus.aspx.cs" Inherits="Class.Layouts.SharePoint.Status" DynamicMasterPageFile="~masterurl/default.master" %>

I don't want any chrome on the page so I want to use the minimal.master. I have tried the following.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ConvertStatus.aspx.cs" Inherits="Class.Layouts.SharePoint.Status" DynamicMasterPageFile="~masterurl/minimal.master" %>

When I do this I then get the error:

Content controls are allowed only in content page that references a master page.

How do I reference the minimal.master?

4

In most cases, IsDlg=1 parameter should help you to display the page without chrome. This works for both application pages and site pages, and doesn't need any coding.

So, if you navigate to

/path/to/your/page/ConvertStatus.aspx?IsDlg=1

, you will get it without any chrome.

2

The minimal.master in SharePoint 2010 is intended for a particular page (search pages I think). It is a slightly unfortunate name because we used to use that to describe master pages with minimal branding and chrome intended for normal pages. The term is now "Starter Master Page" and there are a few around for you to use.

The error is probably due to a mismatch between the content placeholders.

1

Where are you seeing this error?

Many of the placeholders that are normally present in the standard master are not present in the minimal master. Typically if you're referencing a placeholder that's not defined you'll see a generic SharePoint error with a correlation ID to the ULS log (which will then tell you what the invalid reference is).

The master page is typically set at the site or web level, not the page level. I'm not sure I'd approach it from the page level from the perspective of future compatibility. Someone could potentially push a feature in the future that resets it on you.

1

It's worth noting that ~masterurl/default.master is a single, complete token - it is not two separate tokens, and you can't just use ~masterurl without the rest of the token.

The entire token refers to the value stored in the MasterUrl property of the web - if you want to reference minimal.master across your site, you can update that property by Modifying all Site Settings.

Alternatively, deploy your master page to _layouts and reference it directly:

 MasterPageFile="~/_layouts/simple.master"
0

Are you putting your page into Layouts? I'm guessing you may be, looking at the class name. In that case, I think you want to reference Simple.master.

MasterPageFile="~/_layouts/simple.master"

Otherwise, minimal.master is used in Search centers - and it isn't always available for other sites. Check if it is in your _catalogs\masterpage directory.

Also, it's normal to set the SPWeb.CustomMasterUrl or SPWeb.MasterUrl properties to the URL of the file you wish to use. The custom.master and default.master tokens in the page directives get mapped to those MasterUrl properties.

Note, however, that those search pages are a navigational black hole - there's no way of 'browsing' out of them - and users often hate them as a result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.