Looking for something?

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:


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


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


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.


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:

  • 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.

0 Comments 05 January 2009
Tobias Zimmergren

Tobias Zimmergren

Hi, I'm Tobias. I am a Microsoft MVP for SharePoint and I use this site to share my thoughts on tech with you on topics like SharePoint, Office 365, Azure and general web development.

  Malmö, Sweden

Related Post

Comments powered by Disqus