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
<%@ 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.
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.
I’d like to shout out to MVP Eric Schupps for giving me this smart tip.